mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Adjust tuplesort API to have bitwise option flags
This replaces the bool flag for randomAccess. An upcoming patch requires adding another option, so instead of breaking the API for that, then breaking it again one day if we add more options, let's just break it once. Any boolean options we add in the future will just make use of an unused bit in the flags. Any extensions making use of tuplesorts will need to update their code to pass TUPLESORT_RANDOMACCESS instead of true for randomAccess. TUPLESORT_NONE can be used for a set of empty options. Author: David Rowley Reviewed-by: Justin Pryzby Discussion: https://postgr.es/m/CAApHDvoH4ASzsAOyHcxkuY01Qf%2B%2B8JJ0paw%2B03dk%2BW25tQEcNQ%40mail.gmail.com
This commit is contained in:
@@ -118,6 +118,7 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
|
||||
OSAPerQueryState *qstate;
|
||||
MemoryContext gcontext;
|
||||
MemoryContext oldcontext;
|
||||
int tuplesortopt;
|
||||
|
||||
/*
|
||||
* Check we're called as aggregate (and not a window function), and get
|
||||
@@ -283,6 +284,11 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
|
||||
osastate->qstate = qstate;
|
||||
osastate->gcontext = gcontext;
|
||||
|
||||
tuplesortopt = TUPLESORT_NONE;
|
||||
|
||||
if (qstate->rescan_needed)
|
||||
tuplesortopt |= TUPLESORT_RANDOMACCESS;
|
||||
|
||||
/*
|
||||
* Initialize tuplesort object.
|
||||
*/
|
||||
@@ -295,7 +301,7 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
|
||||
qstate->sortNullsFirsts,
|
||||
work_mem,
|
||||
NULL,
|
||||
qstate->rescan_needed);
|
||||
tuplesortopt);
|
||||
else
|
||||
osastate->sortstate = tuplesort_begin_datum(qstate->sortColType,
|
||||
qstate->sortOperator,
|
||||
@@ -303,7 +309,7 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
|
||||
qstate->sortNullsFirst,
|
||||
work_mem,
|
||||
NULL,
|
||||
qstate->rescan_needed);
|
||||
tuplesortopt);
|
||||
|
||||
osastate->number_of_rows = 0;
|
||||
osastate->sort_done = false;
|
||||
|
||||
Reference in New Issue
Block a user