pgsql: Fix mark_placeholder_maybe_needed to handle LATERAL references.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix mark_placeholder_maybe_needed to handle LATERAL references.
Date: 2012-09-01 17:57:02
Message-ID: E1T7rwM-0005ut-A4@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix mark_placeholder_maybe_needed to handle LATERAL references.

If a PlaceHolderVar contains a pulled-up LATERAL reference, its minimum
possible evaluation level might be higher in the join tree than its
original syntactic location. That in turn affects the ph_needed level for
any contained PlaceHolderVars (that is, those PHVs had better propagate up
the join tree at least to the evaluation level of the outer PHV). We got
this mostly right, but mark_placeholder_maybe_needed() failed to account
for the effect, and in consequence could leave the inner PHVs with
ph_may_need less than what their ultimate ph_needed value will be. That's
bad because it could lead to failure to select a join order that will allow
evaluation of the inner PHV at a valid location. Fix that, and add an
Assert that checks that we don't ever set ph_needed to more than
ph_may_need.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4da6439bd8553059766011e2a42c6e39df08717f

Modified Files
--------------
src/backend/optimizer/plan/initsplan.c | 5 +++-
src/backend/optimizer/util/placeholder.c | 15 +++++++++--
src/test/regress/expected/join.out | 40 ++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 11 ++++++++
4 files changed, 67 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-09-01 22:16:38 pgsql: Drop cheap-startup-cost paths during add_path() if we don't need
Previous Message Bruce Momjian 2012-09-01 16:05:05 pgsql: Revert doc patch 305557984dd964ac397c6752e9d0f14646b60f15 as the