diff options
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 559458a7191..ac43be6a6e5 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -782,6 +782,13 @@ inheritance_planner(PlannerInfo *root) subroot.rowMarks = (List *) copyObject(root->rowMarks); /* + * The append_rel_list likewise might contain references to subquery + * RTEs (if any subqueries were flattenable UNION ALLs). So prepare + * to apply ChangeVarNodes to that, too. + */ + subroot.append_rel_list = (List *) copyObject(root->append_rel_list); + + /* * Add placeholders to the child Query's rangetable list to fill the * RT indexes already reserved for subqueries in previous children. * These won't be referenced, so there's no need to make them very @@ -821,6 +828,7 @@ inheritance_planner(PlannerInfo *root) newrti = list_length(subroot.parse->rtable) + 1; ChangeVarNodes((Node *) subroot.parse, rti, newrti, 0); ChangeVarNodes((Node *) subroot.rowMarks, rti, newrti, 0); + ChangeVarNodes((Node *) subroot.append_rel_list, rti, newrti, 0); rte = copyObject(rte); subroot.parse->rtable = lappend(subroot.parse->rtable, rte); @@ -829,7 +837,6 @@ inheritance_planner(PlannerInfo *root) } } - /* We needn't modify the child's append_rel_list */ /* There shouldn't be any OJ info to translate, as yet */ Assert(subroot.join_info_list == NIL); /* and we haven't created PlaceHolderInfos, either */ |