Improve sublink pullup code to handle ANY/EXISTS sublinks that are at top
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Aug 2008 01:20:00 +0000 (01:20 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Aug 2008 01:20:00 +0000 (01:20 +0000)
commit2e2aca944614005dd7903649f2c2b48359f8c1f7
tree964706494e46be3b8015635e678e319ab23d8d41
parent6d29567ee32e359207976c5b9aff6d8522018563
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