|
9 | 9 | *
|
10 | 10 | *
|
11 | 11 | * IDENTIFICATION
|
12 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.312 2009/10/2817:36:50 tgl Exp $ |
| 12 | + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.313 2009/10/2818:51:56 tgl Exp $ |
13 | 13 | *
|
14 | 14 | *-------------------------------------------------------------------------
|
15 | 15 | */
|
@@ -3370,11 +3370,16 @@ static void
|
3370 | 3370 | push_plan(deparse_namespace*dpns,Plan*subplan)
|
3371 | 3371 | {
|
3372 | 3372 | /*
|
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. |
3376 | 3379 | */
|
3377 |
| -if (IsA(subplan,ModifyTable)) |
| 3380 | +if (IsA(subplan,Append)) |
| 3381 | +dpns->outer_plan= (Plan*)linitial(((Append*)subplan)->appendplans); |
| 3382 | +elseif (IsA(subplan,ModifyTable)) |
3378 | 3383 | dpns->outer_plan= (Plan*)linitial(((ModifyTable*)subplan)->plans);
|
3379 | 3384 | else
|
3380 | 3385 | dpns->outer_plan=outerPlan(subplan);
|
|