pgsql: Further adjustments to PlaceHolderVar removal. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Further adjustments to PlaceHolderVar removal.
Date
Msg-id E1ZNm9d-0003Jw-KX@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Further adjustments to PlaceHolderVar removal.

A new test case from Andreas Seltenreich showed that we were still a bit
confused about removing PlaceHolderVars during join removal.  Specifically,
remove_rel_from_query would remove a PHV that was used only underneath
the removable join, even if the place where it's used was the join partner
relation and not the join clause being deleted.  This would lead to a
"too late to create a new PlaceHolderInfo" error later on.  We can defend
against that by checking ph_eval_at to see if the PHV could possibly be
getting used at some partner rel.

Also improve some nearby LATERAL-related logic.  I decided that the check
on ph_lateral needed to take precedence over the check on ph_needed, in
case there's a lateral reference underneath the join being considered.
(That may be impossible, but I'm not convinced of it, and it's easy enough
to defend against the case.)  Also, I realized that remove_rel_from_query's
logic for updating LateralJoinInfos is dead code, because we don't build
those at all until after join removal.

Back-patch to 9.3.  Previous versions didn't have the LATERAL issues, of
course, and they also didn't attempt to remove PlaceHolderInfos during join
removal.  (I'm starting to wonder if changing that was really such a great
idea.)

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/30b4ccdab70aad4178cf6876f25c5bba27035558

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c |   44 +++++++++++------------------
src/test/regress/expected/join.out        |   41 +++++++++++++++++++++++++++
src/test/regress/sql/join.sql             |   25 ++++++++++++++++
3 files changed, 83 insertions(+), 27 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Further adjustments to PlaceHolderVar removal.
Next
From: Andres Freund
Date:
Subject: pgsql: Attempt to work around a 32bit xlc compiler bug from a different