|
16 | 16 | *
|
17 | 17 | *
|
18 | 18 | * IDENTIFICATION
|
19 |
| - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.59 2008/11/11 18:13:32 tgl Exp $ |
| 19 | + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.60 2008/11/11 19:05:21 tgl Exp $ |
20 | 20 | *
|
21 | 21 | *-------------------------------------------------------------------------
|
22 | 22 | */
|
@@ -709,10 +709,9 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
|
709 | 709 | * insert_targetlist_placeholders() will be adjusted, so having created
|
710 | 710 | * them with the subquery's varno is correct.
|
711 | 711 | *
|
712 |
| - * Likewise, relids appearing in AppendRelInfo nodes have to be fixed (but |
713 |
| - * we took care of their translated_vars lists above). We already checked |
714 |
| - * that this won't require introducing multiple subrelids into the |
715 |
| - * single-slot AppendRelInfo structs. |
| 712 | + * Likewise, relids appearing in AppendRelInfo nodes have to be fixed. |
| 713 | + * We already checked that this won't require introducing multiple |
| 714 | + * subrelids into the single-slot AppendRelInfo structs. |
716 | 715 | */
|
717 | 716 | if (parse->hasSubLinks || root->glob->lastPHId != 0 ||
|
718 | 717 | root->append_rel_list)
|
@@ -1679,7 +1678,8 @@ substitute_multiple_relids(Node *node, int varno, Relids subrelids)
|
1679 | 1678 | *
|
1680 | 1679 | * When we pull up a subquery, any AppendRelInfo references to the subquery's
|
1681 | 1680 | * RT index have to be replaced by the substituted relid (and there had better
|
1682 |
| - * be only one). |
| 1681 | + * be only one). We also need to apply substitute_multiple_relids to their |
| 1682 | + * translated_vars lists, since those might contain PlaceHolderVars. |
1683 | 1683 | *
|
1684 | 1684 | * We assume we may modify the AppendRelInfo nodes in-place.
|
1685 | 1685 | */
|
@@ -1708,6 +1708,10 @@ fix_append_rel_relids(List *append_rel_list, int varno, Relids subrelids)
|
1708 | 1708 | subvarno = bms_singleton_member(subrelids);
|
1709 | 1709 | appinfo->child_relid = subvarno;
|
1710 | 1710 | }
|
| 1711 | + |
| 1712 | + /* Also finish fixups for its translated vars */ |
| 1713 | + substitute_multiple_relids((Node *) appinfo->translated_vars, |
| 1714 | + varno, subrelids); |
1711 | 1715 | }
|
1712 | 1716 | }
|
1713 | 1717 |
|
|
0 commit comments