diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-11-11 18:13:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-11-11 18:13:32 +0000 |
commit | 04366799694418ed899e95ce45143a699a75116e (patch) | |
tree | bb54fee3da6b1b10fef6fdeeb7b238fa9b69c6b0 /src/backend/optimizer/prep/prepjointree.c | |
parent | ccc9073f26b8504e5ce168738ffcc4c4c8d2fa0a (diff) |
Get rid of adjust_appendrel_attr_needed(), which has been broken ever since
we extended the appendrel mechanism to support UNION ALL optimization. The
reason nobody noticed was that we are not actually using attr_needed data for
appendrel children; hence it seems more reasonable to rip it out than fix it.
Back-patch to 8.2 because an Assert failure is possible in corner cases.
Per examination of an example from Jim Nasby.
In HEAD, also get rid of AppendRelInfo.col_mappings, which is quite inadequate
to represent UNION ALL situations; depend entirely on translated_vars instead.
Diffstat (limited to 'src/backend/optimizer/prep/prepjointree.c')
-rw-r--r-- | src/backend/optimizer/prep/prepjointree.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index b15a0e5dd40..b5882a5771a 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.58 2008/10/22 20:17:52 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.59 2008/11/11 18:13:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,9 +54,8 @@ static Node *pull_up_simple_union_all(PlannerInfo *root, Node *jtnode, static void pull_up_union_leaf_queries(Node *setOp, PlannerInfo *root, int parentRTindex, Query *setOpQuery, int childRToffset); -static void make_setop_translation_lists(Query *query, - Index newvarno, - List **col_mappings, List **translated_vars); +static void make_setop_translation_list(Query *query, Index newvarno, + List **translated_vars); static bool is_simple_subquery(Query *subquery); static bool is_simple_union_all(Query *subquery); static bool is_simple_union_all_recurse(Node *setOp, Query *setOpQuery, @@ -839,9 +838,8 @@ pull_up_union_leaf_queries(Node *setOp, PlannerInfo *root, int parentRTindex, appinfo->child_relid = childRTindex; appinfo->parent_reltype = InvalidOid; appinfo->child_reltype = InvalidOid; - make_setop_translation_lists(setOpQuery, childRTindex, - &appinfo->col_mappings, - &appinfo->translated_vars); + make_setop_translation_list(setOpQuery, childRTindex, + &appinfo->translated_vars); appinfo->parent_reloid = InvalidOid; root->append_rel_list = lappend(root->append_rel_list, appinfo); @@ -874,17 +872,16 @@ pull_up_union_leaf_queries(Node *setOp, PlannerInfo *root, int parentRTindex, } /* - * make_setop_translation_lists - * Build the lists of translations from parent Vars to child Vars for - * a UNION ALL member. We need both a column number mapping list - * and a list of Vars representing the child columns. + * make_setop_translation_list + * Build the list of translations from parent Vars to child Vars for + * a UNION ALL member. (At this point it's just a simple list of + * referencing Vars, but if we succeed in pulling up the member + * subquery, the Vars will get replaced by pulled-up expressions.) */ static void -make_setop_translation_lists(Query *query, - Index newvarno, - List **col_mappings, List **translated_vars) +make_setop_translation_list(Query *query, Index newvarno, + List **translated_vars) { - List *numbers = NIL; List *vars = NIL; ListCell *l; @@ -895,7 +892,6 @@ make_setop_translation_lists(Query *query, if (tle->resjunk) continue; - numbers = lappend_int(numbers, tle->resno); vars = lappend(vars, makeVar(newvarno, tle->resno, exprType((Node *) tle->expr), @@ -903,7 +899,6 @@ make_setop_translation_lists(Query *query, 0)); } - *col_mappings = numbers; *translated_vars = vars; } |