Thread: pgsql: Improve sublink pullup code to handle ANY/EXISTS sublinks that

pgsql: Improve sublink pullup code to handle ANY/EXISTS sublinks that

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/src/backend/optimizer/plan:
        initsplan.c (r1.141 -> r1.142)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/initsplan.c?r1=1.141&r2=1.142)
        planner.c (r1.241 -> r1.242)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/planner.c?r1=1.241&r2=1.242)
        subselect.c (r1.133 -> r1.134)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/subselect.c?r1=1.133&r2=1.134)
    pgsql/src/backend/optimizer/prep:
        prepjointree.c (r1.52 -> r1.53)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/prep/prepjointree.c?r1=1.52&r2=1.53)
    pgsql/src/include/optimizer:
        prep.h (r1.61 -> r1.62)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/prep.h?r1=1.61&r2=1.62)
        subselect.h (r1.32 -> r1.33)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/subselect.h?r1=1.32&r2=1.33)