mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Support MergeAppend plans, to allow sorted output from append relations.
This patch eliminates the former need to sort the output of an Append scan when an ordered scan of an inheritance tree is wanted. This should be particularly useful for fast-start cases such as queries with LIMIT. Original patch by Greg Stark, with further hacking by Hans-Jurgen Schonig, Robert Haas, and Tom Lane.
This commit is contained in:
@ -202,6 +202,31 @@ _copyAppend(Append *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyMergeAppend
|
||||
*/
|
||||
static MergeAppend *
|
||||
_copyMergeAppend(MergeAppend *from)
|
||||
{
|
||||
MergeAppend *newnode = makeNode(MergeAppend);
|
||||
|
||||
/*
|
||||
* copy node superclass fields
|
||||
*/
|
||||
CopyPlanFields((Plan *) from, (Plan *) newnode);
|
||||
|
||||
/*
|
||||
* copy remainder of node
|
||||
*/
|
||||
COPY_NODE_FIELD(mergeplans);
|
||||
COPY_SCALAR_FIELD(numCols);
|
||||
COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
|
||||
COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
|
||||
COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyRecursiveUnion
|
||||
*/
|
||||
@ -3625,6 +3650,9 @@ copyObject(void *from)
|
||||
case T_Append:
|
||||
retval = _copyAppend(from);
|
||||
break;
|
||||
case T_MergeAppend:
|
||||
retval = _copyMergeAppend(from);
|
||||
break;
|
||||
case T_RecursiveUnion:
|
||||
retval = _copyRecursiveUnion(from);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user