Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 77c666f

Browse files
committed
Un-break EXPLAIN for Append plans. I messed this up a few days ago while
adding the ModifyTable node type --- I had been thinking ModifyTable should replace Append as a special case in push_plan(), but actually both of them have to be special-cased.
1 parent be6899f commit 77c666f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/backend/utils/adt/ruleutils.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.312 2009/10/28 17:36:50 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.313 2009/10/28 18:51:56 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -3370,11 +3370,16 @@ static void
33703370
push_plan(deparse_namespace *dpns, Plan *subplan)
33713371
{
33723372
/*
3373-
* We special-case ModifyTable to pretend that the first child plan is the
3374-
* OUTER referent; otherwise normal. This is to support RETURNING lists
3375-
* containing references to non-target relations.
3373+
* We special-case Append to pretend that the first child plan is the
3374+
* OUTER referent; we have to interpret OUTER Vars in the Append's tlist
3375+
* according to one of the children, and the first one is the most
3376+
* natural choice. Likewise special-case ModifyTable to pretend that the
3377+
* first child plan is the OUTER referent; this is to support RETURNING
3378+
* lists containing references to non-target relations.
33763379
*/
3377-
if (IsA(subplan, ModifyTable))
3380+
if (IsA(subplan, Append))
3381+
dpns->outer_plan = (Plan *) linitial(((Append *) subplan)->appendplans);
3382+
else if (IsA(subplan, ModifyTable))
33783383
dpns->outer_plan = (Plan *) linitial(((ModifyTable *) subplan)->plans);
33793384
else
33803385
dpns->outer_plan = outerPlan(subplan);

0 commit comments

Comments
 (0)