/*
* apply_child_basequals
* Populate childrel's base restriction quals from parent rel's quals,
- * translating Vars using appinfo and re-checking for quals which are
- * constant-TRUE or constant-FALSE when applied to this child relation.
+ * translating them using appinfo.
*
* If any of the resulting clauses evaluate to constant false or NULL, we
* return false and don't apply any quals. Caller should mark the relation as
rinfo->security_level,
NULL, NULL, NULL);
- /* Restriction is proven always false */
- if (restriction_is_always_false(root, childrinfo))
- return false;
- /* Restriction is proven always true, so drop it */
- if (restriction_is_always_true(root, childrinfo))
- continue;
-
childquals = lappend(childquals, childrinfo);
/* track minimum security level among child quals */
- cq_min_security = Min(cq_min_security, rinfo->security_level);
+ cq_min_security = Min(cq_min_security, childrinfo->security_level);
}
}
break;
}
- /*
- * 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.)
+ * variables. If any resulting clause is reduced to constant FALSE or
+ * NULL, 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)
{
if (!apply_child_basequals(root, parent, rel, rte, appinfo))
{
/*
- * Restriction clause reduced to constant FALSE or NULL. Mark as
- * dummy so we won't scan this relation.
+ * A restriction clause reduced to constant FALSE or NULL after
+ * substitution. Mark the child as dummy so that it need not be
+ * scanned.
*/
mark_dummy_rel(rel);
}
}
+ /* Save the finished struct in the query's simple_rel_array */
+ root->simple_rel_array[relid] = rel;
+
return rel;
}