mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Rename sort support integer comparators for clarity
The previous names used "unsigned" for Datum-width abbreviated keys and "signed" for 64-bit signed integers. This may have made more sense when Datum width was platform-dependent, but commit 805c64f84 added a 32-bit unsigned variant for OIDs, so it makes even less sense now. Rename all to be explicit about signedness and width. Suggested-by: David Rowley <dgrowleyml@gmail.com> Discussion: https://postgr.es/m/CAApHDvrNMz5ahN1x=uK9yscTogmLupfLBy-_qMW9Z+k=HE5u_A@mail.gmail.com
This commit is contained in:
@@ -1750,7 +1750,7 @@ gist_point_sortsupport(PG_FUNCTION_ARGS)
|
||||
|
||||
if (ssup->abbreviate)
|
||||
{
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
ssup->abbrev_converter = gist_bbox_zorder_abbrev_convert;
|
||||
ssup->abbrev_abort = gist_bbox_zorder_abbrev_abort;
|
||||
ssup->abbrev_full_comparator = gist_bbox_zorder_cmp;
|
||||
|
||||
@@ -275,7 +275,7 @@ btint8sortsupport(PG_FUNCTION_ARGS)
|
||||
{
|
||||
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
|
||||
|
||||
ssup->comparator = ssup_datum_signed_cmp;
|
||||
ssup->comparator = ssup_datum_int64_cmp;
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ btoid8sortsupport(PG_FUNCTION_ARGS)
|
||||
{
|
||||
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
|
||||
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
@@ -1127,7 +1127,7 @@ bytea_abbrev_convert(Datum original, SortSupport ssup)
|
||||
/*
|
||||
* Byteswap on little-endian machines.
|
||||
*
|
||||
* This is needed so that ssup_datum_unsigned_cmp() works correctly on all
|
||||
* This is needed so that ssup_datum_uint64_cmp() works correctly on all
|
||||
* platforms.
|
||||
*/
|
||||
res = DatumBigEndianToNative(res);
|
||||
@@ -1234,7 +1234,7 @@ bytea_sortsupport(PG_FUNCTION_ARGS)
|
||||
|
||||
ssup->ssup_extra = bss;
|
||||
ssup->abbrev_full_comparator = ssup->comparator;
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
ssup->abbrev_converter = bytea_abbrev_convert;
|
||||
ssup->abbrev_abort = bytea_abbrev_abort;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ macaddr_sortsupport(PG_FUNCTION_ARGS)
|
||||
|
||||
if (ssup->abbreviate)
|
||||
{
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
ssup->abbrev_converter = macaddr_abbrev_convert;
|
||||
ssup->abbrev_abort = macaddr_abbrev_abort;
|
||||
ssup->abbrev_full_comparator = macaddr_fast_cmp;
|
||||
@@ -419,7 +419,7 @@ macaddr_abbrev_convert(Datum original, SortSupport ssup)
|
||||
/*
|
||||
* Byteswap on little-endian machines.
|
||||
*
|
||||
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
||||
* This is needed so that ssup_datum_uint64_cmp() (an unsigned integer
|
||||
* 3-way comparator) works correctly on all platforms. Without this, the
|
||||
* comparator would have to call memcmp() with a pair of pointers to the
|
||||
* first byte of each abbreviated key, which is slower.
|
||||
|
||||
@@ -451,7 +451,7 @@ network_sortsupport(PG_FUNCTION_ARGS)
|
||||
|
||||
ssup->ssup_extra = uss;
|
||||
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
ssup->abbrev_converter = network_abbrev_convert;
|
||||
ssup->abbrev_abort = network_abbrev_abort;
|
||||
ssup->abbrev_full_comparator = network_fast_cmp;
|
||||
|
||||
@@ -2292,7 +2292,7 @@ timestamp_sortsupport(PG_FUNCTION_ARGS)
|
||||
{
|
||||
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
|
||||
|
||||
ssup->comparator = ssup_datum_signed_cmp;
|
||||
ssup->comparator = ssup_datum_int64_cmp;
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ uuid_sortsupport(PG_FUNCTION_ARGS)
|
||||
|
||||
ssup->ssup_extra = uss;
|
||||
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
ssup->abbrev_converter = uuid_abbrev_convert;
|
||||
ssup->abbrev_abort = uuid_abbrev_abort;
|
||||
ssup->abbrev_full_comparator = uuid_fast_cmp;
|
||||
@@ -441,7 +441,7 @@ uuid_abbrev_convert(Datum original, SortSupport ssup)
|
||||
/*
|
||||
* Byteswap on little-endian machines.
|
||||
*
|
||||
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
||||
* This is needed so that ssup_datum_uint64_cmp() (an unsigned integer
|
||||
* 3-way comparator) works correctly on all platforms. If we didn't do
|
||||
* this, the comparator would have to call memcmp() with a pair of
|
||||
* pointers to the first byte of each abbreviated key, which is slower.
|
||||
|
||||
@@ -1794,7 +1794,7 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
|
||||
initHyperLogLog(&sss->abbr_card, 10);
|
||||
initHyperLogLog(&sss->full_card, 10);
|
||||
ssup->abbrev_full_comparator = ssup->comparator;
|
||||
ssup->comparator = ssup_datum_unsigned_cmp;
|
||||
ssup->comparator = ssup_datum_uint64_cmp;
|
||||
ssup->abbrev_converter = varstr_abbrev_convert;
|
||||
ssup->abbrev_abort = varstr_abbrev_abort;
|
||||
}
|
||||
@@ -2179,7 +2179,7 @@ done:
|
||||
/*
|
||||
* Byteswap on little-endian machines.
|
||||
*
|
||||
* This is needed so that ssup_datum_unsigned_cmp() (an unsigned integer
|
||||
* This is needed so that ssup_datum_uint64_cmp() (an unsigned integer
|
||||
* 3-way comparator) works correctly on all platforms. If we didn't do
|
||||
* this, the comparator would have to call memcmp() with a pair of
|
||||
* pointers to the first byte of each abbreviated key, which is slower.
|
||||
|
||||
@@ -2587,9 +2587,9 @@ normalize_datum(Datum orig, SortSupport ssup)
|
||||
{
|
||||
Datum norm_datum1;
|
||||
|
||||
if (ssup->comparator == ssup_datum_signed_cmp)
|
||||
if (ssup->comparator == ssup_datum_int64_cmp)
|
||||
norm_datum1 = orig + (Int64GetDatum(PG_INT64_MAX)) + 1;
|
||||
else if (ssup->comparator == ssup_datum_unsigned_cmp)
|
||||
else if (ssup->comparator == ssup_datum_uint64_cmp)
|
||||
norm_datum1 = orig;
|
||||
else
|
||||
{
|
||||
@@ -3010,8 +3010,8 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
|
||||
|
||||
/* Does it compare as an integer? */
|
||||
if (state->memtupcount >= QSORT_THRESHOLD &&
|
||||
(ssup->comparator == ssup_datum_unsigned_cmp ||
|
||||
ssup->comparator == ssup_datum_signed_cmp ||
|
||||
(ssup->comparator == ssup_datum_uint64_cmp ||
|
||||
ssup->comparator == ssup_datum_int64_cmp ||
|
||||
ssup->comparator == ssup_datum_uint32_cmp ||
|
||||
ssup->comparator == ssup_datum_int32_cmp))
|
||||
{
|
||||
@@ -3449,7 +3449,7 @@ free_sort_tuple(Tuplesortstate *state, SortTuple *stup)
|
||||
}
|
||||
|
||||
int
|
||||
ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
|
||||
ssup_datum_uint64_cmp(Datum x, Datum y, SortSupport ssup)
|
||||
{
|
||||
if (x < y)
|
||||
return -1;
|
||||
@@ -3460,7 +3460,7 @@ ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
|
||||
}
|
||||
|
||||
int
|
||||
ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup)
|
||||
ssup_datum_int64_cmp(Datum x, Datum y, SortSupport ssup)
|
||||
{
|
||||
int64 xx = DatumGetInt64(x);
|
||||
int64 yy = DatumGetInt64(y);
|
||||
|
||||
@@ -272,8 +272,8 @@ ApplySortAbbrevFullComparator(Datum datum1, bool isNull1,
|
||||
* Datatypes that install these as their comparator or abbreviated comparator
|
||||
* are eligible for faster sorting.
|
||||
*/
|
||||
extern int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup);
|
||||
extern int ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup);
|
||||
extern int ssup_datum_uint64_cmp(Datum x, Datum y, SortSupport ssup);
|
||||
extern int ssup_datum_int64_cmp(Datum x, Datum y, SortSupport ssup);
|
||||
extern int ssup_datum_uint32_cmp(Datum x, Datum y, SortSupport ssup);
|
||||
extern int ssup_datum_int32_cmp(Datum x, Datum y, SortSupport ssup);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user