mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +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:
@ -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
|
||||
|
Reference in New Issue
Block a user