mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
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
This commit is contained in:
@@ -379,7 +379,9 @@ ApplySortAbbrevFullComparator(Datum datum1, bool isNull1,
|
||||
* 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 */
|
||||
|
||||
Reference in New Issue
Block a user