|
22 | 22 | *
|
23 | 23 | *
|
24 | 24 | * 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 $ |
26 | 26 | *
|
27 | 27 | *-------------------------------------------------------------------------
|
28 | 28 | */
|
@@ -1636,7 +1636,62 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context)
|
1636 | 1636 | Assert(!IsA(node, SpecialJoinInfo));
|
1637 | 1637 | Assert(!IsA(node, AppendRelInfo));
|
1638 | 1638 | 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 | + } |
1640 | 1695 |
|
1641 | 1696 | /*
|
1642 | 1697 | * NOTE: we do not need to recurse into sublinks, because they should
|
|
0 commit comments