summaryrefslogtreecommitdiffstats
path: root/src/backend/optimizer/path
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/path')
-rw-r--r--src/backend/optimizer/path/equivclass.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
index 9f39f46..06f89a6 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -1851,6 +1851,21 @@ create_join_clause(PlannerInfo *root,
rightem->em_nullable_relids),
ec->ec_min_security);
+ /*
+ * If either EM is a child, force the clause's clause_relids to include
+ * the relid(s) of the child rel. In normal cases it would already, but
+ * not if we are considering appendrel child relations with pseudoconstant
+ * translated variables (i.e., UNION ALL sub-selects with constant output
+ * items). We must do this so that join_clause_is_movable_into() will
+ * think that the clause should be evaluated at the correct place.
+ */
+ if (leftem->em_is_child)
+ rinfo->clause_relids = bms_add_members(rinfo->clause_relids,
+ leftem->em_relids);
+ if (rightem->em_is_child)
+ rinfo->clause_relids = bms_add_members(rinfo->clause_relids,
+ rightem->em_relids);
+
/* Mark the clause as redundant, or not */
rinfo->parent_ec = parent_ec;