diff options
Diffstat (limited to 'src/backend/optimizer/prep/prepunion.c')
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 2f06e1bf53..f09ddb1d23 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -22,7 +22,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.138 2007/02/19 07:03:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.139 2007/02/22 22:00:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -169,6 +169,7 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, RangeTblRef *rtr = (RangeTblRef *) setOp; RangeTblEntry *rte = rt_fetch(rtr->rtindex, root->parse->rtable); Query *subquery = rte->subquery; + PlannerInfo *subroot; Plan *subplan, *plan; @@ -180,7 +181,7 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, subplan = subquery_planner(root->glob, subquery, root->query_level + 1, tuple_fraction, - NULL); + &subroot); /* * Add a SubqueryScan with the caller-requested targetlist @@ -193,7 +194,8 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, refnames_tlist), NIL, rtr->rtindex, - subplan); + subplan, + subroot->parse->rtable); /* * We don't bother to determine the subquery's output ordering since @@ -223,7 +225,7 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, * output columns. * * XXX you don't really want to know about this: setrefs.c will apply - * replace_vars_with_subplan_refs() to the Result node's tlist. This + * fix_upper_expr() to the Result node's tlist. This * would fail if the Vars generated by generate_setop_tlist() were not * exactly equal() to the corresponding tlist entries of the subplan. * However, since the subplan was generated by generate_union_plan() @@ -235,7 +237,8 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, !tlist_same_datatypes(plan->targetlist, colTypes, junkOK)) { plan = (Plan *) - make_result(generate_setop_tlist(colTypes, flag, + make_result(root, + generate_setop_tlist(colTypes, flag, 0, false, plan->targetlist, @@ -1216,28 +1219,6 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context) Assert(!IsA(node, SubLink)); Assert(!IsA(node, Query)); - /* - * BUT: although we don't need to recurse into subplans, we do need to - * make sure that they are copied, not just referenced as - * expression_tree_mutator will do by default. Otherwise we'll have the - * same subplan node referenced from each arm of the finished APPEND plan, - * which will cause trouble in the executor. This is a kluge that should - * go away when we redesign querytrees. - */ - if (is_subplan(node)) - { - SubPlan *subplan; - - /* Copy the node and process subplan args */ - node = expression_tree_mutator(node, adjust_appendrel_attrs_mutator, - (void *) context); - /* Make sure we have separate copies of subplan and its rtable */ - subplan = (SubPlan *) node; - subplan->plan = copyObject(subplan->plan); - subplan->rtable = copyObject(subplan->rtable); - return node; - } - return expression_tree_mutator(node, adjust_appendrel_attrs_mutator, (void *) context); } |