@@ -471,7 +471,7 @@ struct Tuplesortstate
471471
472472/* These are specific to the index_btree subcase: */
473473bool enforceUnique ;/* complain if we find duplicate tuples */
474- bool uniqueNullsNotDistinct ;/* unique constraint null treatment */
474+ bool uniqueNullsNotDistinct ;/* unique constraint null treatment */
475475
476476/* These are specific to the index_hash subcase: */
477477uint32 high_mask ;/* masks for sortable part of hash code */
@@ -708,15 +708,16 @@ qsort_tuple_unsigned_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
708708return compare ;
709709
710710/*
711- * No need to waste effort calling the tiebreak function when there are
712- *no other keys to sort on.
711+ * No need to waste effort calling the tiebreak function when there are no
712+ * other keys to sort on.
713713 */
714714if (state -> onlyKey != NULL )
715715return 0 ;
716716
717717return state -> comparetup (a ,b ,state );
718718}
719719
720+ #if SIZEOF_DATUM >=8
720721/* Used if first key's comparator is ssup_datum_signed_compare */
721722static pg_attribute_always_inline int
722723qsort_tuple_signed_compare (SortTuple * a ,SortTuple * b ,Tuplesortstate * state )
@@ -731,14 +732,15 @@ qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
731732return compare ;
732733
733734/*
734- * No need to waste effort calling the tiebreak function when there are
735- *no other keys to sort on.
735+ * No need to waste effort calling the tiebreak function when there are no
736+ * other keys to sort on.
736737 */
737738if (state -> onlyKey != NULL )
738739return 0 ;
739740
740741return state -> comparetup (a ,b ,state );
741742}
743+ #endif
742744
743745/* Used if first key's comparator is ssup_datum_int32_compare */
744746static pg_attribute_always_inline int
@@ -747,15 +749,15 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
747749int compare ;
748750
749751compare = ApplyInt32SortComparator (a -> datum1 ,a -> isnull1 ,
750- b -> datum1 ,b -> isnull1 ,
751- & state -> sortKeys [0 ]);
752+ b -> datum1 ,b -> isnull1 ,
753+ & state -> sortKeys [0 ]);
752754
753755if (compare != 0 )
754756return compare ;
755757
756758/*
757- * No need to waste effort calling the tiebreak function when there are
758- *no other keys to sort on.
759+ * No need to waste effort calling the tiebreak function when there are no
760+ * other keys to sort on.
759761 */
760762if (state -> onlyKey != NULL )
761763return 0 ;
@@ -781,6 +783,7 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
781783#define ST_DEFINE
782784#include "lib/sort_template.h"
783785
786+ #if SIZEOF_DATUM >=8
784787#define ST_SORT qsort_tuple_signed
785788#define ST_ELEMENT_TYPE SortTuple
786789#define ST_COMPARE (a ,b ,state ) qsort_tuple_signed_compare(a, b, state)
@@ -789,6 +792,7 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
789792#define ST_SCOPE static
790793#define ST_DEFINE
791794#include "lib/sort_template.h"
795+ #endif
792796
793797#define ST_SORT qsort_tuple_int32
794798#define ST_ELEMENT_TYPE SortTuple
@@ -3662,23 +3666,22 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
36623666{
36633667if (state -> sortKeys [0 ].comparator == ssup_datum_unsigned_cmp )
36643668{
3665- elog (DEBUG1 ,"qsort_tuple_unsigned" );
36663669qsort_tuple_unsigned (state -> memtuples ,
36673670state -> memtupcount ,
36683671state );
36693672return ;
36703673}
3674+ #if SIZEOF_DATUM >=8
36713675else if (state -> sortKeys [0 ].comparator == ssup_datum_signed_cmp )
36723676{
3673- elog (DEBUG1 ,"qsort_tuple_signed" );
36743677qsort_tuple_signed (state -> memtuples ,
36753678state -> memtupcount ,
36763679state );
36773680return ;
36783681}
3682+ #endif
36793683else if (state -> sortKeys [0 ].comparator == ssup_datum_int32_cmp )
36803684{
3681- elog (DEBUG1 ,"qsort_tuple_int32" );
36823685qsort_tuple_int32 (state -> memtuples ,
36833686state -> memtupcount ,
36843687state );
@@ -3689,13 +3692,11 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
36893692/* Can we use the single-key sort function? */
36903693if (state -> onlyKey != NULL )
36913694{
3692- elog (DEBUG1 ,"qsort_ssup" );
36933695qsort_ssup (state -> memtuples ,state -> memtupcount ,
36943696state -> onlyKey );
36953697}
36963698else
36973699{
3698- elog (DEBUG1 ,"qsort_tuple" );
36993700qsort_tuple (state -> memtuples ,
37003701state -> memtupcount ,
37013702state -> comparetup ,
@@ -4907,16 +4908,12 @@ ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
49074908return 0 ;
49084909}
49094910
4911+ #if SIZEOF_DATUM >=8
49104912int
49114913ssup_datum_signed_cmp (Datum x ,Datum y ,SortSupport ssup )
49124914{
4913- #if SIZEOF_DATUM == 8
4914- int64 xx = (int64 )x ;
4915- int64 yy = (int64 )y ;
4916- #else
4917- int32 xx = (int32 )x ;
4918- int32 yy = (int32 )y ;
4919- #endif
4915+ int64 xx = DatumGetInt64 (x );
4916+ int64 yy = DatumGetInt64 (y );
49204917
49214918if (xx < yy )
49224919return -1 ;
@@ -4925,12 +4922,13 @@ ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup)
49254922else
49264923return 0 ;
49274924}
4925+ #endif
49284926
49294927int
49304928ssup_datum_int32_cmp (Datum x ,Datum y ,SortSupport ssup )
49314929{
4932- int32 xx = ( int32 ) x ;
4933- int32 yy = ( int32 ) y ;
4930+ int32 xx = DatumGetInt32 ( x ) ;
4931+ int32 yy = DatumGetInt32 ( y ) ;
49344932
49354933if (xx < yy )
49364934return -1 ;