Skip to content

Commit f959390

Browse files
committed
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.
1 parent b6bde52 commit f959390

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

src/backend/optimizer/prep/prepunion.c

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.172 2009/07/06 18:26:30 tgl Exp $
25+
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.173 2009/08/13 16:53:09 tgl Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -1636,7 +1636,62 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context)
16361636
Assert(!IsA(node, SpecialJoinInfo));
16371637
Assert(!IsA(node, AppendRelInfo));
16381638
Assert(!IsA(node, PlaceHolderInfo));
1639-
Assert(!IsA(node, RestrictInfo));
1639+
1640+
/*
1641+
* We have to process RestrictInfo nodes specially. (Note: although
1642+
* set_append_rel_pathlist will hide RestrictInfos in the parent's
1643+
* baserestrictinfo list from us, it doesn't hide those in joininfo.)
1644+
*/
1645+
if (IsA(node, RestrictInfo))
1646+
{
1647+
RestrictInfo *oldinfo = (RestrictInfo *) node;
1648+
RestrictInfo *newinfo = makeNode(RestrictInfo);
1649+
1650+
/* Copy all flat-copiable fields */
1651+
memcpy(newinfo, oldinfo, sizeof(RestrictInfo));
1652+
1653+
/* Recursively fix the clause itself */
1654+
newinfo->clause = (Expr *)
1655+
adjust_appendrel_attrs_mutator((Node *) oldinfo->clause, context);
1656+
1657+
/* and the modified version, if an OR clause */
1658+
newinfo->orclause = (Expr *)
1659+
adjust_appendrel_attrs_mutator((Node *) oldinfo->orclause, context);
1660+
1661+
/* adjust relid sets too */
1662+
newinfo->clause_relids = adjust_relid_set(oldinfo->clause_relids,
1663+
context->parent_relid,
1664+
context->child_relid);
1665+
newinfo->required_relids = adjust_relid_set(oldinfo->required_relids,
1666+
context->parent_relid,
1667+
context->child_relid);
1668+
newinfo->nullable_relids = adjust_relid_set(oldinfo->nullable_relids,
1669+
context->parent_relid,
1670+
context->child_relid);
1671+
newinfo->left_relids = adjust_relid_set(oldinfo->left_relids,
1672+
context->parent_relid,
1673+
context->child_relid);
1674+
newinfo->right_relids = adjust_relid_set(oldinfo->right_relids,
1675+
context->parent_relid,
1676+
context->child_relid);
1677+
1678+
/*
1679+
* Reset cached derivative fields, since these might need to have
1680+
* different values when considering the child relation.
1681+
*/
1682+
newinfo->eval_cost.startup = -1;
1683+
newinfo->norm_selec = -1;
1684+
newinfo->outer_selec = -1;
1685+
newinfo->left_ec = NULL;
1686+
newinfo->right_ec = NULL;
1687+
newinfo->left_em = NULL;
1688+
newinfo->right_em = NULL;
1689+
newinfo->scansel_cache = NIL;
1690+
newinfo->left_bucketsize = -1;
1691+
newinfo->right_bucketsize = -1;
1692+
1693+
return (Node *) newinfo;
1694+
}
16401695

16411696
/*
16421697
* NOTE: we do not need to recurse into sublinks, because they should

0 commit comments

Comments
 (0)