Fix broken comparetup_datum code.
Commit 337b6f5ecf
contained the entirely
fanciful 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.
This commit is contained in:
parent
6c41948c39
commit
17b985b1a0
@ -344,6 +344,12 @@ struct Tuplesortstate
|
|||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
SortSupport sortKeys; /* array of length nKeys */
|
SortSupport sortKeys; /* array of length nKeys */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This variable is shared by the single-key MinimalTuple case and the
|
||||||
|
* Datum case. Otherwise it's NULL.
|
||||||
|
*/
|
||||||
|
SortSupport onlyKey;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These variables are specific to the CLUSTER case; they are set by
|
* These variables are specific to the CLUSTER case; they are set by
|
||||||
* tuplesort_begin_cluster. Note CLUSTER also uses tupDesc and
|
* tuplesort_begin_cluster. Note CLUSTER also uses tupDesc and
|
||||||
@ -365,9 +371,6 @@ struct Tuplesortstate
|
|||||||
/* These are specific to the index_hash subcase: */
|
/* These are specific to the index_hash subcase: */
|
||||||
uint32 hash_mask; /* mask for sortable part of hash code */
|
uint32 hash_mask; /* mask for sortable part of hash code */
|
||||||
|
|
||||||
/* This is initialized when, and only when, there's just one key. */
|
|
||||||
SortSupport onlyKey;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These variables are specific to the Datum case; they are set by
|
* These variables are specific to the Datum case; they are set by
|
||||||
* tuplesort_begin_datum and used only by the DatumTuple routines.
|
* tuplesort_begin_datum and used only by the DatumTuple routines.
|
||||||
@ -497,7 +500,8 @@ static void reversedirection_datum(Tuplesortstate *state);
|
|||||||
static void free_sort_tuple(Tuplesortstate *state, SortTuple *stup);
|
static void free_sort_tuple(Tuplesortstate *state, SortTuple *stup);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special version of qsort, just for SortTuple objects.
|
* Special versions of qsort just for SortTuple objects. We have one for the
|
||||||
|
* single-key case (qsort_ssup) and one for multi-key cases (qsort_tuple).
|
||||||
*/
|
*/
|
||||||
#include "qsort_tuple.c"
|
#include "qsort_tuple.c"
|
||||||
|
|
||||||
@ -1236,6 +1240,7 @@ tuplesort_performsort(Tuplesortstate *state)
|
|||||||
*/
|
*/
|
||||||
if (state->memtupcount > 1)
|
if (state->memtupcount > 1)
|
||||||
{
|
{
|
||||||
|
/* Can we use the single-key sort function? */
|
||||||
if (state->onlyKey != NULL)
|
if (state->onlyKey != NULL)
|
||||||
qsort_ssup(state->memtuples, state->memtupcount,
|
qsort_ssup(state->memtuples, state->memtupcount,
|
||||||
state->onlyKey);
|
state->onlyKey);
|
||||||
@ -3061,7 +3066,6 @@ comparetup_index_btree(const SortTuple *a, const SortTuple *b,
|
|||||||
* they *must* get compared at some stage of the sort --- otherwise the
|
* they *must* get compared at some stage of the sort --- otherwise the
|
||||||
* sort algorithm wouldn't have checked whether one must appear before the
|
* sort algorithm wouldn't have checked whether one must appear before the
|
||||||
* other.
|
* other.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if (state->enforceUnique && !equal_hasnull)
|
if (state->enforceUnique && !equal_hasnull)
|
||||||
{
|
{
|
||||||
@ -3243,9 +3247,9 @@ reversedirection_index_hash(Tuplesortstate *state)
|
|||||||
static int
|
static int
|
||||||
comparetup_datum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
|
comparetup_datum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
|
||||||
{
|
{
|
||||||
/* Not currently needed */
|
return ApplySortComparator(a->datum1, a->isnull1,
|
||||||
elog(ERROR, "comparetup_datum() should not be called");
|
b->datum1, b->isnull1,
|
||||||
return 0;
|
state->onlyKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user