aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2022-05-11 11:38:13 +1200
committerDavid Rowley <drowley@postgresql.org>2022-05-11 11:38:13 +1200
commitc90c16591c438e4146b1d4b9e4539f80b58845ba (patch)
tree26e6edd196336b83e23e25d8f404acbcf643d627 /src/backend/utils/adt
parentaff45c879e018d18951a9bc4cd8e2a395ee52c43 (diff)
downloadpostgresql-c90c16591c438e4146b1d4b9e4539f80b58845ba.tar.gz
postgresql-c90c16591c438e4146b1d4b9e4539f80b58845ba.zip
Fix some incorrect preprocessor tests in tuplesort specializations
697492434 added 3 new quicksort specialization functions for common datatypes. That commit was not very consistent in how it would determine if we're compiling for 32-bit or 64-bit machines. It would sometimes use USE_FLOAT8_BYVAL and at other times check if SIZEOF_DATUM == 8. This could cause theoretical problems due to the way USE_FLOAT8_BYVAL is now defined based on SIZEOF_VOID_P >= 8. If pointers for some reason were ever larger than 8-bytes then we'd end up doing 32-bit comparisons mistakenly. Let's just always check SIZEOF_DATUM >= 8. It also seems that ssup_datum_signed_cmp is just never used on 32-bit builds, so let's just ifdef that out to make sure we never accidentally use that comparison function on such machines. This also allows us to ifdef out 1 of the 3 new specialization quicksort functions in 32-bit builds which seems to shrink down the binary by over 4KB on my machine. In passing, also add the missing DatumGetInt32() / DatumGetInt64() macros in the comparison functions. Discussion: https://postgr.es/m/CAApHDvqcQExRhtRa9hJrJB_5egs3SUfOcutP3m+3HO8A+fZTPA@mail.gmail.com Reviewed-by: John Naylor
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/timestamp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 552b631ba78..8acb725bc8f 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -2176,7 +2176,7 @@ timestamp_cmp(PG_FUNCTION_ARGS)
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)
@@ -2193,7 +2193,7 @@ timestamp_sortsupport(PG_FUNCTION_ARGS)
{
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.