pgsql: Fix handling of PlaceHolderVars in nestloop parameter management

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix handling of PlaceHolderVars in nestloop parameter management
Date: 2011-11-03 04:51:26
Message-ID: E1RLpGw-0005K1-1s@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e4e60e7b6125e77f679861ebf43cc6b9f9dbf16d

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Simon Riggs 2011-11-03 08:54:24 pgsql: Improve docs for timing and skipping of checkpoints
Previous Message Tom Lane 2011-11-03 04:51:25 pgsql: Fix handling of PlaceHolderVars in nestloop parameter management