Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7761b9f

Browse files
committed
Use correct datum macros in more tuplesort specialization functions.
Also clarify that ApplySignedSortComparator() is not built on 32-bit machines. Folow-up to c90c165 Reviewed-by: David Rowley Discussion: https://www.postgresql.org/message-id/CAFBsxsFmt4_JUP8XgSJqwaAS9a9s8K8_PvMu%3Dj%3DDfwU%3D8QjNPw%40mail.gmail.com
1 parent d70b95a commit 7761b9f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/include/utils/sortsupport.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ ApplyUnsignedSortComparator(Datum datum1, bool isNull1,
262262
return compare;
263263
}
264264

265+
#if SIZEOF_DATUM >= 8
265266
static inline int
266267
ApplySignedSortComparator(Datum datum1, bool isNull1,
267268
Datum datum2, bool isNull2,
@@ -287,19 +288,15 @@ ApplySignedSortComparator(Datum datum1, bool isNull1,
287288
}
288289
else
289290
{
290-
#if SIZEOF_DATUM == 8
291-
compare = (int64) datum1 < (int64) datum2 ? -1 :
292-
(int64) datum1 > (int64) datum2 ? 1 : 0;
293-
#else
294-
compare = (int32) datum1 < (int32) datum2 ? -1 :
295-
(int32) datum1 > (int32) datum2 ? 1 : 0;
296-
#endif
291+
compare = DatumGetInt64(datum1) < DatumGetInt64(datum2) ? -1 :
292+
DatumGetInt64(datum1) > DatumGetInt64(datum2) ? 1 : 0;
297293
if (ssup->ssup_reverse)
298294
INVERT_COMPARE_RESULT(compare);
299295
}
300296

301297
return compare;
302298
}
299+
#endif
303300

304301
static inline int
305302
ApplyInt32SortComparator(Datum datum1, bool isNull1,
@@ -326,8 +323,8 @@ ApplyInt32SortComparator(Datum datum1, bool isNull1,
326323
}
327324
else
328325
{
329-
compare = (int32) datum1 < (int32) datum2 ? -1 :
330-
(int32) datum1 > (int32) datum2 ? 1 : 0;
326+
compare = DatumGetInt32(datum1) < DatumGetInt32(datum2) ? -1 :
327+
DatumGetInt32(datum1) > DatumGetInt32(datum2) ? 1 : 0;
331328
if (ssup->ssup_reverse)
332329
INVERT_COMPARE_RESULT(compare);
333330
}

0 commit comments

Comments
 (0)