Improve sublink pullup code to handle ANY/EXISTS sublinks that are at top

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 19e34b62395b36513a8e6c35ddfbeef12dd1e89f
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2008-08-17T01:20:00Z
Releases: 8.4.0
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.

Files