PG_RETURN_INT32(A_LESS_THAN_B);
}
-#ifndef USE_FLOAT8_BYVAL
+#if SIZEOF_DATUM < 8
static int
btint8fastcmp(Datum x, Datum y, SortSupport ssup)
{
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
-#ifdef USE_FLOAT8_BYVAL
+#if SIZEOF_DATUM >= 8
ssup->comparator = ssup_datum_signed_cmp;
#else
ssup->comparator = btint8fastcmp;
PG_RETURN_INT32(timestamp_cmp_internal(dt1, dt2));
}
-#ifndef USE_FLOAT8_BYVAL
+#if SIZEOF_DATUM < 8
/* note: this is used for timestamptz also */
static int
timestamp_fastcmp(Datum x, Datum y, SortSupport ssup)
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
-#ifdef USE_FLOAT8_BYVAL
+#if SIZEOF_DATUM >= 8
/*
* If this build has pass-by-value timestamps, then we can use a standard
* comparator function.
return state->comparetup(a, b, state);
}
+#if SIZEOF_DATUM >= 8
/* Used if first key's comparator is ssup_datum_signed_compare */
static pg_attribute_always_inline int
qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
return state->comparetup(a, b, state);
}
+#endif
/* Used if first key's comparator is ssup_datum_int32_compare */
static pg_attribute_always_inline int
#define ST_DEFINE
#include "lib/sort_template.h"
+#if SIZEOF_DATUM >= 8
#define ST_SORT qsort_tuple_signed
#define ST_ELEMENT_TYPE SortTuple
#define ST_COMPARE(a, b, state) qsort_tuple_signed_compare(a, b, state)
#define ST_SCOPE static
#define ST_DEFINE
#include "lib/sort_template.h"
+#endif
#define ST_SORT qsort_tuple_int32
#define ST_ELEMENT_TYPE SortTuple
state);
return;
}
+#if SIZEOF_DATUM >= 8
else if (state->sortKeys[0].comparator == ssup_datum_signed_cmp)
{
elog(DEBUG1, "qsort_tuple_signed");
state);
return;
}
+#endif
else if (state->sortKeys[0].comparator == ssup_datum_int32_cmp)
{
elog(DEBUG1, "qsort_tuple_int32");
return 0;
}
+#if SIZEOF_DATUM >= 8
int
ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup)
{
-#if SIZEOF_DATUM == 8
- int64 xx = (int64) x;
- int64 yy = (int64) y;
-#else
- int32 xx = (int32) x;
- int32 yy = (int32) y;
-#endif
+ int64 xx = DatumGetInt64(x);
+ int64 yy = DatumGetInt64(y);
if (xx < yy)
return -1;
else
return 0;
}
+#endif
int
ssup_datum_int32_cmp(Datum x, Datum y, SortSupport ssup)
{
- int32 xx = (int32) x;
- int32 yy = (int32) y;
+ int32 xx = DatumGetInt32(x);
+ int32 yy = DatumGetInt32(y);
if (xx < yy)
return -1;
* are eligible for faster sorting.
*/
extern int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup);
+#if SIZEOF_DATUM >= 8
extern int ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup);
+#endif
extern int ssup_datum_int32_cmp(Datum x, Datum y, SortSupport ssup);
/* Other functions in utils/sort/sortsupport.c */