On Wed, May 11, 2022 at 6:43 AM David Rowley <dgrowle...@gmail.com> wrote: > > I pushed this after I made a small adjustment to #ifdef out the > qsort_tuple_signed sort specialization in 32-bit builds. On testing a > 32-bit build with the patch I proposed, I was getting a warning about > that function being unused.
Earlier I looked at your patch, but didn't think to check the rest of the code affected by this commit. Do we also need something like the attached, for the ApplyXYZSortComparator functions? (I don't have a 32-bit platform to test on) -- John Naylor EDB: http://www.enterprisedb.com
diff --git a/src/include/utils/sortsupport.h b/src/include/utils/sortsupport.h index ae8f4852a8..140a9f9ffc 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); }