Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit17b985b

Browse files
committed
Fix broken comparetup_datum code.
Commit337b6f5 contained the entirelyfanciful assumption that it had made comparetup_datum unreachable.Reported and patched by Takashi Yamamoto.Fix up some not terribly accurate/useful comments from that commit, too.
1 parent6c41948 commit17b985b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

‎src/backend/utils/sort/tuplesort.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ struct Tuplesortstate
344344
TupleDesctupDesc;
345345
SortSupportsortKeys;/* array of length nKeys */
346346

347+
/*
348+
* This variable is shared by the single-key MinimalTuple case and the
349+
* Datum case. Otherwise it's NULL.
350+
*/
351+
SortSupportonlyKey;
352+
347353
/*
348354
* These variables are specific to the CLUSTER case; they are set by
349355
* tuplesort_begin_cluster. Note CLUSTER also uses tupDesc and
@@ -365,9 +371,6 @@ struct Tuplesortstate
365371
/* These are specific to the index_hash subcase: */
366372
uint32hash_mask;/* mask for sortable part of hash code */
367373

368-
/* This is initialized when, and only when, there's just one key. */
369-
SortSupportonlyKey;
370-
371374
/*
372375
* These variables are specific to the Datum case; they are set by
373376
* tuplesort_begin_datum and used only by the DatumTuple routines.
@@ -497,7 +500,8 @@ static void reversedirection_datum(Tuplesortstate *state);
497500
staticvoidfree_sort_tuple(Tuplesortstate*state,SortTuple*stup);
498501

499502
/*
500-
* Special version of qsort, just for SortTuple objects.
503+
* Special versions of qsort just for SortTuple objects. We have one for the
504+
* single-key case (qsort_ssup) and one for multi-key cases (qsort_tuple).
501505
*/
502506
#include"qsort_tuple.c"
503507

@@ -1236,6 +1240,7 @@ tuplesort_performsort(Tuplesortstate *state)
12361240
*/
12371241
if (state->memtupcount>1)
12381242
{
1243+
/* Can we use the single-key sort function? */
12391244
if (state->onlyKey!=NULL)
12401245
qsort_ssup(state->memtuples,state->memtupcount,
12411246
state->onlyKey);
@@ -3061,7 +3066,6 @@ comparetup_index_btree(const SortTuple *a, const SortTuple *b,
30613066
* they *must* get compared at some stage of the sort --- otherwise the
30623067
* sort algorithm wouldn't have checked whether one must appear before the
30633068
* other.
3064-
*
30653069
*/
30663070
if (state->enforceUnique&& !equal_hasnull)
30673071
{
@@ -3243,9 +3247,9 @@ reversedirection_index_hash(Tuplesortstate *state)
32433247
staticint
32443248
comparetup_datum(constSortTuple*a,constSortTuple*b,Tuplesortstate*state)
32453249
{
3246-
/* Not currently needed */
3247-
elog(ERROR,"comparetup_datum() should not be called");
3248-
return0;
3250+
returnApplySortComparator(a->datum1,a->isnull1,
3251+
b->datum1,b->isnull1,
3252+
state->onlyKey);
32493253
}
32503254

32513255
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp