aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.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/utils/adt/ruleutils.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/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index f1c1d04ee09..b5437612a92 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -2174,15 +2174,17 @@ set_deparse_planstate(deparse_namespace *dpns, PlanState *ps)
dpns->planstate = ps;
/*
- * We special-case Append to pretend that the first child plan is the
- * OUTER referent; we have to interpret OUTER Vars in the Append's tlist
- * according to one of the children, and the first one is the most natural
- * choice. Likewise special-case ModifyTable to pretend that the first
- * child plan is the OUTER referent; this is to support RETURNING lists
- * containing references to non-target relations.
+ * We special-case Append and MergeAppend to pretend that the first child
+ * plan is the OUTER referent; we have to interpret OUTER Vars in their
+ * tlists according to one of the children, and the first one is the most
+ * natural choice. Likewise special-case ModifyTable to pretend that the
+ * first child plan is the OUTER referent; this is to support RETURNING
+ * lists containing references to non-target relations.
*/
if (IsA(ps, AppendState))
dpns->outer_planstate = ((AppendState *) ps)->appendplans[0];
+ else if (IsA(ps, MergeAppendState))
+ dpns->outer_planstate = ((MergeAppendState *) ps)->mergeplans[0];
else if (IsA(ps, ModifyTableState))
dpns->outer_planstate = ((ModifyTableState *) ps)->mt_plans[0];
else