aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execCurrent.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-10-14 16:56:39 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2010-10-14 16:57:57 -0400
commit11cad29c91524aac1d0b61e0ea0357398ab79bf8 (patch)
treeec9053dfee621437146f29ce20904a9949b3f2ae /src/backend/executor/execCurrent.c
parent30e749dece0e6502d4dd0a3b2892eab61f8c073b (diff)
downloadpostgresql-11cad29c91524aac1d0b61e0ea0357398ab79bf8.tar.gz
postgresql-11cad29c91524aac1d0b61e0ea0357398ab79bf8.zip
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/executor/execCurrent.c')
-rw-r--r--src/backend/executor/execCurrent.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/backend/executor/execCurrent.c b/src/backend/executor/execCurrent.c
index 79a1425a974..cf552a016a5 100644
--- a/src/backend/executor/execCurrent.c
+++ b/src/backend/executor/execCurrent.c
@@ -296,6 +296,29 @@ search_plan_tree(PlanState *node, Oid table_oid)
}
/*
+ * Similarly for MergeAppend
+ */
+ case T_MergeAppendState:
+ {
+ MergeAppendState *mstate = (MergeAppendState *) node;
+ ScanState *result = NULL;
+ int i;
+
+ for (i = 0; i < mstate->ms_nplans; i++)
+ {
+ ScanState *elem = search_plan_tree(mstate->mergeplans[i],
+ table_oid);
+
+ if (!elem)
+ continue;
+ if (result)
+ return NULL; /* multiple matches */
+ result = elem;
+ }
+ return result;
+ }
+
+ /*
* Result and Limit can be descended through (these are safe
* because they always return their input's current row)
*/