diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-10-14 16:56:39 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-10-14 16:57:57 -0400 |
| commit | 11cad29c91524aac1d0b61e0ea0357398ab79bf8 (patch) | |
| tree | ec9053dfee621437146f29ce20904a9949b3f2ae /src/backend/nodes/copyfuncs.c | |
| parent | 30e749dece0e6502d4dd0a3b2892eab61f8c073b (diff) | |
| download | postgresql-11cad29c91524aac1d0b61e0ea0357398ab79bf8.tar.gz | |
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.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
| -rw-r--r-- | src/backend/nodes/copyfuncs.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 2118a333a3..6ce3984bff 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -203,6 +203,31 @@ _copyAppend(Append *from) } /* + * _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 */ static RecursiveUnion * @@ -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; |
