/*
* Remove any references to relid or ojrelid from the RestrictInfo.
*
- * We only bother to clean out bits in clause_relids and required_relids,
+ * We only bother to clean out bits in the RestrictInfo's various relid sets,
* not nullingrel bits in contained Vars and PHVs. (This might have to be
* improved sometime.) However, if the RestrictInfo contains an OR clause
* we have to also clean up the sub-clauses.
rinfo->required_relids = bms_copy(rinfo->required_relids);
rinfo->required_relids = bms_del_member(rinfo->required_relids, relid);
rinfo->required_relids = bms_del_member(rinfo->required_relids, ojrelid);
+ /* Likewise for incompatible_relids */
+ rinfo->incompatible_relids = bms_copy(rinfo->incompatible_relids);
+ rinfo->incompatible_relids = bms_del_member(rinfo->incompatible_relids, relid);
+ rinfo->incompatible_relids = bms_del_member(rinfo->incompatible_relids, ojrelid);
+ /* Likewise for outer_relids */
+ rinfo->outer_relids = bms_copy(rinfo->outer_relids);
+ rinfo->outer_relids = bms_del_member(rinfo->outer_relids, relid);
+ rinfo->outer_relids = bms_del_member(rinfo->outer_relids, ojrelid);
+ /* Likewise for left_relids */
+ rinfo->left_relids = bms_copy(rinfo->left_relids);
+ rinfo->left_relids = bms_del_member(rinfo->left_relids, relid);
+ rinfo->left_relids = bms_del_member(rinfo->left_relids, ojrelid);
+ /* Likewise for right_relids */
+ rinfo->right_relids = bms_copy(rinfo->right_relids);
+ rinfo->right_relids = bms_del_member(rinfo->right_relids, relid);
+ rinfo->right_relids = bms_del_member(rinfo->right_relids, ojrelid);
/* If it's an OR, recurse to clean up sub-clauses */
if (restriction_is_or_clause(rinfo))
-> Seq Scan on onek t4
(13 rows)
+-- bug #19460: we need to clean up RestrictInfos more than we had been doing
+explain (costs off)
+select * from
+ (select 1::int as id) as lhs
+full join
+ (select dummy_source.id
+ from (select null::int as id) as dummy_source
+ left join (select a.id from a where a.id = 42) as sub
+ on sub.id = dummy_source.id
+ ) as rhs
+on lhs.id = rhs.id;
+ QUERY PLAN
+--------------------------------------
+ Hash Full Join
+ Hash Cond: ((1) = (NULL::integer))
+ -> Result
+ -> Hash
+ -> Result
+(5 rows)
+
+explain (costs off)
+select * from
+ (select 1::int as id) as lhs
+full join
+ (select dummy_source.id
+ from (select 2::int as id) as dummy_source
+ left join (select a.id from a) as sub
+ on sub.id = dummy_source.id
+ ) as rhs
+on lhs.id = rhs.id;
+ QUERY PLAN
+--------------------------
+ Hash Full Join
+ Hash Cond: ((1) = (2))
+ -> Result
+ -> Hash
+ -> Result
+(5 rows)
+
-- More tests of correct placement of pseudoconstant quals
-- simple constant-false condition
explain (costs off)
left join onek t4
on t2.q2 < t3.unique2;
+-- bug #19460: we need to clean up RestrictInfos more than we had been doing
+explain (costs off)
+select * from
+ (select 1::int as id) as lhs
+full join
+ (select dummy_source.id
+ from (select null::int as id) as dummy_source
+ left join (select a.id from a where a.id = 42) as sub
+ on sub.id = dummy_source.id
+ ) as rhs
+on lhs.id = rhs.id;
+
+explain (costs off)
+select * from
+ (select 1::int as id) as lhs
+full join
+ (select dummy_source.id
+ from (select 2::int as id) as dummy_source
+ left join (select a.id from a) as sub
+ on sub.id = dummy_source.id
+ ) as rhs
+on lhs.id = rhs.id;
+
-- More tests of correct placement of pseudoconstant quals
-- simple constant-false condition