aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Naylor <john.naylor@postgresql.org>2022-05-12 09:18:21 +0700
committerJohn Naylor <john.naylor@postgresql.org>2022-05-12 09:20:32 +0700
commit7761b9faabae15217fe0e5bbb54230b425222f81 (patch)
treefef72ce43919d71bb80f6a6e72f7f6279a668fe3
parentd70b95a7178af84212487438b5509871090f5b05 (diff)
downloadpostgresql-7761b9faabae15217fe0e5bbb54230b425222f81.tar.gz
postgresql-7761b9faabae15217fe0e5bbb54230b425222f81.zip
Use correct datum macros in more tuplesort specialization functions.
Also clarify that ApplySignedSortComparator() is not built on 32-bit machines. Folow-up to c90c16591 Reviewed-by: David Rowley Discussion: https://www.postgresql.org/message-id/CAFBsxsFmt4_JUP8XgSJqwaAS9a9s8K8_PvMu%3Dj%3DDfwU%3D8QjNPw%40mail.gmail.com
-rw-r--r--src/include/utils/sortsupport.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/include/utils/sortsupport.h b/src/include/utils/sortsupport.h
index ae8f4852a8b..140a9f9ffc4 100644
--- a/src/include/utils/sortsupport.h
+++ b/src/include/utils/sortsupport.h
@@ -262,6 +262,7 @@ ApplyUnsignedSortComparator(Datum datum1, bool isNull1,
return compare;
}
+#if SIZEOF_DATUM >= 8
static inline int
ApplySignedSortComparator(Datum datum1, bool isNull1,
Datum datum2, bool isNull2,
@@ -287,19 +288,15 @@ ApplySignedSortComparator(Datum datum1, bool isNull1,
}
else
{
-#if SIZEOF_DATUM == 8
- compare = (int64) datum1 < (int64) datum2 ? -1 :
- (int64) datum1 > (int64) datum2 ? 1 : 0;
-#else
- compare = (int32) datum1 < (int32) datum2 ? -1 :
- (int32) datum1 > (int32) datum2 ? 1 : 0;
-#endif
+ compare = DatumGetInt64(datum1) < DatumGetInt64(datum2) ? -1 :
+ DatumGetInt64(datum1) > DatumGetInt64(datum2) ? 1 : 0;
if (ssup->ssup_reverse)
INVERT_COMPARE_RESULT(compare);
}
return compare;
}
+#endif
static inline int
ApplyInt32SortComparator(Datum datum1, bool isNull1,
@@ -326,8 +323,8 @@ ApplyInt32SortComparator(Datum datum1, bool isNull1,
}
else
{
- compare = (int32) datum1 < (int32) datum2 ? -1 :
- (int32) datum1 > (int32) datum2 ? 1 : 0;
+ compare = DatumGetInt32(datum1) < DatumGetInt32(datum2) ? -1 :
+ DatumGetInt32(datum1) > DatumGetInt32(datum2) ? 1 : 0;
if (ssup->ssup_reverse)
INVERT_COMPARE_RESULT(compare);
}