Skip to content

Commit 1ffa817

Browse files
committed
Update src/tuplessort15.c for new changes upto 2022-06-01
1 parent 210abdd commit 1ffa817

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

src/tuplesort15.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ struct Tuplesortstate
471471

472472
/* These are specific to the index_btree subcase: */
473473
bool 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: */
477477
uint32 high_mask; /* masks for sortable part of hash code */
@@ -708,15 +708,16 @@ qsort_tuple_unsigned_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
708708
return 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
*/
714714
if (state->onlyKey != NULL)
715715
return 0;
716716

717717
return state->comparetup(a, b, state);
718718
}
719719

720+
#if SIZEOF_DATUM >= 8
720721
/* Used if first key's comparator is ssup_datum_signed_compare */
721722
static pg_attribute_always_inline int
722723
qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
@@ -731,14 +732,15 @@ qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
731732
return 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
*/
737738
if (state->onlyKey != NULL)
738739
return 0;
739740

740741
return state->comparetup(a, b, state);
741742
}
743+
#endif
742744

743745
/* Used if first key's comparator is ssup_datum_int32_compare */
744746
static pg_attribute_always_inline int
@@ -747,15 +749,15 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
747749
int compare;
748750

749751
compare = ApplyInt32SortComparator(a->datum1, a->isnull1,
750-
b->datum1, b->isnull1,
751-
&state->sortKeys[0]);
752+
b->datum1, b->isnull1,
753+
&state->sortKeys[0]);
752754

753755
if (compare != 0)
754756
return 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
*/
760762
if (state->onlyKey != NULL)
761763
return 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
{
36633667
if (state->sortKeys[0].comparator == ssup_datum_unsigned_cmp)
36643668
{
3665-
elog(DEBUG1, "qsort_tuple_unsigned");
36663669
qsort_tuple_unsigned(state->memtuples,
36673670
state->memtupcount,
36683671
state);
36693672
return;
36703673
}
3674+
#if SIZEOF_DATUM >= 8
36713675
else if (state->sortKeys[0].comparator == ssup_datum_signed_cmp)
36723676
{
3673-
elog(DEBUG1, "qsort_tuple_signed");
36743677
qsort_tuple_signed(state->memtuples,
36753678
state->memtupcount,
36763679
state);
36773680
return;
36783681
}
3682+
#endif
36793683
else if (state->sortKeys[0].comparator == ssup_datum_int32_cmp)
36803684
{
3681-
elog(DEBUG1, "qsort_tuple_int32");
36823685
qsort_tuple_int32(state->memtuples,
36833686
state->memtupcount,
36843687
state);
@@ -3689,13 +3692,11 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
36893692
/* Can we use the single-key sort function? */
36903693
if (state->onlyKey != NULL)
36913694
{
3692-
elog(DEBUG1, "qsort_ssup");
36933695
qsort_ssup(state->memtuples, state->memtupcount,
36943696
state->onlyKey);
36953697
}
36963698
else
36973699
{
3698-
elog(DEBUG1, "qsort_tuple");
36993700
qsort_tuple(state->memtuples,
37003701
state->memtupcount,
37013702
state->comparetup,
@@ -4907,16 +4908,12 @@ ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
49074908
return 0;
49084909
}
49094910

4911+
#if SIZEOF_DATUM >= 8
49104912
int
49114913
ssup_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

49214918
if (xx < yy)
49224919
return -1;
@@ -4925,12 +4922,13 @@ ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup)
49254922
else
49264923
return 0;
49274924
}
4925+
#endif
49284926

49294927
int
49304928
ssup_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

49354933
if (xx < yy)
49364934
return -1;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy