summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/prepunion.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-07-06 18:26:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-07-06 18:26:30 +0000
commit9b27eab71c47f4f21d0e487b1d7ad277a85735e0 (patch)
treebeda036b38bbdce77fa13464927e1ddbc20def71 /src/backend/optimizer/prep/prepunion.c
parentbf6570abef3df08c7cd4d318d61217b2f95ccbb2 (diff)
Fix set_append_rel_pathlist() to deal intelligently with cases where
substituting a child rel's output expressions into the appendrel's restriction clauses yields a pseudoconstant restriction. We might be able to skip scanning that child rel entirely (if we get constant FALSE), or generate a one-time filter. 8.3 more or less accidentally generated plans that weren't completely stupid in these cases, but that was only because an extra recursive level of subquery_planner() always occurred and allowed const-simplification to happen. 8.4's ability to pull up appendrel members with non-Var outputs exposes the fact that we need to work harder here. Per gripe from Sergey Burladyan.
Diffstat (limited to 'src/backend/optimizer/prep/prepunion.c')
-rw-r--r--src/backend/optimizer/prep/prepunion.c54
1 files changed, 2 insertions, 52 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c
index b5e10a91801..956b9559f82 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.171 2009/06/11 14:48:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.172 2009/07/06 18:26:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1636,57 +1636,7 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context)
Assert(!IsA(node, SpecialJoinInfo));
Assert(!IsA(node, AppendRelInfo));
Assert(!IsA(node, PlaceHolderInfo));
-
- /*
- * We have to process RestrictInfo nodes specially.
- */
- if (IsA(node, RestrictInfo))
- {
- RestrictInfo *oldinfo = (RestrictInfo *) node;
- RestrictInfo *newinfo = makeNode(RestrictInfo);
-
- /* Copy all flat-copiable fields */
- memcpy(newinfo, oldinfo, sizeof(RestrictInfo));
-
- /* Recursively fix the clause itself */
- newinfo->clause = (Expr *)
- adjust_appendrel_attrs_mutator((Node *) oldinfo->clause, context);
-
- /* and the modified version, if an OR clause */
- newinfo->orclause = (Expr *)
- adjust_appendrel_attrs_mutator((Node *) oldinfo->orclause, context);
-
- /* adjust relid sets too */
- newinfo->clause_relids = adjust_relid_set(oldinfo->clause_relids,
- context->parent_relid,
- context->child_relid);
- newinfo->required_relids = adjust_relid_set(oldinfo->required_relids,
- context->parent_relid,
- context->child_relid);
- newinfo->left_relids = adjust_relid_set(oldinfo->left_relids,
- context->parent_relid,
- context->child_relid);
- newinfo->right_relids = adjust_relid_set(oldinfo->right_relids,
- context->parent_relid,
- context->child_relid);
-
- /*
- * Reset cached derivative fields, since these might need to have
- * different values when considering the child relation.
- */
- newinfo->eval_cost.startup = -1;
- newinfo->norm_selec = -1;
- newinfo->outer_selec = -1;
- newinfo->left_ec = NULL;
- newinfo->right_ec = NULL;
- newinfo->left_em = NULL;
- newinfo->right_em = NULL;
- newinfo->scansel_cache = NIL;
- newinfo->left_bucketsize = -1;
- newinfo->right_bucketsize = -1;
-
- return (Node *) newinfo;
- }
+ Assert(!IsA(node, RestrictInfo));
/*
* NOTE: we do not need to recurse into sublinks, because they should