Simplify overcomplicated (and overly restrictive) test to see whether an
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Feb 2009 00:01:03 +0000 (00:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Feb 2009 00:01:03 +0000 (00:01 +0000)
commit56e8e3c2c888c3d966176d2763f39a5538231cb8
tree0f52ab0a88d84ee83e2a933cdd88c813c1bbe037
parentc4aee17c9aac4d11369a22cd89a9686c77e9b096
Simplify overcomplicated (and overly restrictive) test to see whether an
IS NULL condition is rendered redundant by detection of an antijoin.
If we know that a join is an antijoin, then *any* Var coming out of its
righthand side must be NULL, not only the joining column(s).  Also,
it's still gonna be null after being passed up through higher joins,
whether they're outer joins or not.  I was misled by a faulty analogy
to reduce_outer_joins() in the original coding.  But consider

select * from a left join b on a.x = b.y where b.y is null and b.z is null;

The first IS NULL condition justifies deciding that the join is an antijoin
(if the = is strict) and then the second one is just plain redundant.
src/backend/optimizer/plan/initsplan.c