summaryrefslogtreecommitdiffstats
path: root/src/backend/optimizer/path/equivclass.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 19:16:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 19:16:24 +0000
commit2a0f262beff32ba86bcb58f3273214e5d0517c09 (patch)
tree24c0ad10dab36bbd5c22743d3c88c4e0ccd5bc65 /src/backend/optimizer/path/equivclass.c
parentReleasing progress-linux version 16.2-2~progress7.99u1. (diff)
downloadpostgresql-16-2a0f262beff32ba86bcb58f3273214e5d0517c09.tar.xz
postgresql-16-2a0f262beff32ba86bcb58f3273214e5d0517c09.zip
Merging upstream version 16.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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 7fa502d..e79c7e4 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -1885,6 +1885,21 @@ create_join_clause(PlannerInfo *root,
rightem->em_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);
+
/* If it's a child clause, copy the parent's rinfo_serial */
if (parent_rinfo)
rinfo->rinfo_serial = parent_rinfo->rinfo_serial;