diff options
Diffstat (limited to 'src/backend/optimizer/util/relnode.c')
-rw-r--r-- | src/backend/optimizer/util/relnode.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index d791c4108d2..0c125e42e88 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -373,10 +373,20 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent) } /* - * Copy the parent's quals to the child, with appropriate substitution of - * variables. If any constant false or NULL clauses turn up, we can mark - * the child as dummy right away. (We must do this immediately so that - * pruning works correctly when recursing in expand_partitioned_rtentry.) + * We must apply the partially filled in RelOptInfo before calling + * apply_child_basequals due to some transformations within that function + * which require the RelOptInfo to be available in the simple_rel_array. + */ + root->simple_rel_array[relid] = rel; + + /* + * Apply the parent's quals to the child, with appropriate substitution of + * variables. If the resulting clause is constant-FALSE or NULL after + * applying transformations, apply_child_basequals returns false to + * indicate that scanning this relation won't yield any rows. In this + * case, we mark the child as dummy right away. (We must do this + * immediately so that pruning works correctly when recursing in + * expand_partitioned_rtentry.) */ if (parent) { @@ -386,16 +396,13 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent) if (!apply_child_basequals(root, parent, rel, rte, appinfo)) { /* - * Some restriction clause reduced to constant FALSE or NULL after - * substitution, so this child need not be scanned. + * Restriction clause reduced to constant FALSE or NULL. Mark as + * dummy so we won't scan this relation. */ mark_dummy_rel(rel); } } - /* Save the finished struct in the query's simple_rel_array */ - root->simple_rel_array[relid] = rel; - return rel; } |