Improve sublink pullup code to handle ANY/EXISTS sublinks that are at top
commit92e4b7f80fd3f1266a387349a54aadfe6b6deb7b
authortgl <tgl>
Sun, 17 Aug 2008 01:20:00 +0000 (17 01:20 +0000)
committertgl <tgl>
Sun, 17 Aug 2008 01:20:00 +0000 (17 01:20 +0000)
tree73ab341038d4711edad061ac17088e12fdc8b998
parentc1e57b35a0d92adca8548e549843ffadc1e907a5
Improve sublink pullup code to handle ANY/EXISTS sublinks that are at top
level of a JOIN/ON clause, not only at top level of WHERE.  (However, we
can't do this in an outer join's ON clause, unless the ANY/EXISTS refers
only to the nullable side of the outer join, so that it can effectively
be pushed down into the nullable side.)  Per request from Kevin Grittner.

In passing, fix a bug in the initial implementation of EXISTS pullup:
it would Assert if the EXIST's WHERE clause used a join alias variable.
Since we haven't yet flattened join aliases when this transformation
happens, it's necessary to include join relids in the computed set of
RHS relids.
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepjointree.c
src/include/optimizer/prep.h
src/include/optimizer/subselect.h