diff options
Diffstat (limited to 'src/backend/access/nbtree/nbtcompare.c')
-rw-r--r-- | src/backend/access/nbtree/nbtcompare.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c index da4ce7b4f1f..40de3878fe5 100644 --- a/src/backend/access/nbtree/nbtcompare.c +++ b/src/backend/access/nbtree/nbtcompare.c @@ -119,26 +119,12 @@ btint4cmp(PG_FUNCTION_ARGS) PG_RETURN_INT32(A_LESS_THAN_B); } -static int -btint4fastcmp(Datum x, Datum y, SortSupport ssup) -{ - int32 a = DatumGetInt32(x); - int32 b = DatumGetInt32(y); - - if (a > b) - return A_GREATER_THAN_B; - else if (a == b) - return 0; - else - return A_LESS_THAN_B; -} - Datum btint4sortsupport(PG_FUNCTION_ARGS) { SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0); - ssup->comparator = btint4fastcmp; + ssup->comparator = ssup_datum_int32_cmp; PG_RETURN_VOID(); } @@ -156,6 +142,7 @@ btint8cmp(PG_FUNCTION_ARGS) PG_RETURN_INT32(A_LESS_THAN_B); } +#ifndef USE_FLOAT8_BYVAL static int btint8fastcmp(Datum x, Datum y, SortSupport ssup) { @@ -169,13 +156,18 @@ btint8fastcmp(Datum x, Datum y, SortSupport ssup) else return A_LESS_THAN_B; } +#endif Datum btint8sortsupport(PG_FUNCTION_ARGS) { SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0); +#ifdef USE_FLOAT8_BYVAL + ssup->comparator = ssup_datum_signed_cmp; +#else ssup->comparator = btint8fastcmp; +#endif PG_RETURN_VOID(); } |