diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-13 16:53:15 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-13 16:53:15 +0000 |
commit | 69eab4e387755e6f815efb22745eeefbd447a43d (patch) | |
tree | c53262143f2d984cdee593385a84bb8c25ed9f62 /src | |
parent | 3dc494f0a334e71c5e88cf803316cf739cf6fe44 (diff) | |
download | postgresql-69eab4e387755e6f815efb22745eeefbd447a43d.tar.gz postgresql-69eab4e387755e6f815efb22745eeefbd447a43d.zip |
Put back adjust_appendrel_attrs()'s code for dealing with RestrictInfo.
I mistakenly removed it last month, thinking it was no longer needed ---
but it is still needed for dealing with joininfo lists. Fortunately this
bit of brain fade hadn't made it into any released versions yet.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 4ca17c7447f..743ab251a9b 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.2.1 2009/07/06 18:26:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.171.2.2 2009/08/13 16:53:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1636,7 +1636,62 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context) Assert(!IsA(node, SpecialJoinInfo)); Assert(!IsA(node, AppendRelInfo)); Assert(!IsA(node, PlaceHolderInfo)); - Assert(!IsA(node, RestrictInfo)); + + /* + * We have to process RestrictInfo nodes specially. (Note: although + * set_append_rel_pathlist will hide RestrictInfos in the parent's + * baserestrictinfo list from us, it doesn't hide those in joininfo.) + */ + 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->nullable_relids = adjust_relid_set(oldinfo->nullable_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; + } /* * NOTE: we do not need to recurse into sublinks, because they should |