pgsql: Fix handling of PlaceHolderVars in nestloop parameter management - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix handling of PlaceHolderVars in nestloop parameter management
Date
Msg-id E1RLpGv-0005Jz-UH@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix handling of PlaceHolderVars in nestloop parameter management.

If we use a PlaceHolderVar from the outer relation in an inner indexscan,
we need to reference the PlaceHolderVar as such as the value to be passed
in from the outer relation.  The previous code effectively tried to
reconstruct the PHV from its component expression, which doesn't work since
(a) the Vars therein aren't necessarily bubbled up far enough, and (b) it
would be the wrong semantics anyway because of the possibility that the PHV
is supposed to have gone to null at some point before the current join.
Point (a) led to "variable not found in subplan target list" planner
errors, but point (b) would have led to silently wrong answers.
Per report from Roger Niederland.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7e3bf99baa18524de6ef1492cb3057314da97e68

Modified Files
--------------
src/backend/executor/nodeNestloop.c     |    1 +
src/backend/optimizer/plan/createplan.c |   71 ++++++++++++++++++++++++++++---
src/backend/optimizer/plan/setrefs.c    |    4 ++
src/backend/optimizer/plan/subselect.c  |   61 ++++++++++++++++++++++++++-
src/include/nodes/plannodes.h           |    4 +-
src/include/nodes/relation.h            |   21 +++++----
src/include/optimizer/subselect.h       |    4 +-
src/test/regress/expected/join.out      |   38 ++++++++++++++++
src/test/regress/sql/join.sql           |   23 ++++++++++
9 files changed, 208 insertions(+), 19 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Avoid scanning nulls at the beginning of a btree index scan.
Next
From: Simon Riggs
Date:
Subject: pgsql: Improve docs for timing and skipping of checkpoints