pgsql: Remove ph_may_need from PlaceHolderInfo, with attendant simplifi - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Remove ph_may_need from PlaceHolderInfo, with attendant simplifi
Date
Msg-id E1V9jiW-0005v9-8l@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Remove ph_may_need from PlaceHolderInfo, with attendant simplifications.

The planner logic that attempted to make a preliminary estimate of the
ph_needed levels for PlaceHolderVars seems to be completely broken by
lateral references.  Fortunately, the potential join order optimization
that this code supported seems to be of relatively little value in
practice; so let's just get rid of it rather than trying to fix it.

Getting rid of this allows fairly substantial simplifications in
placeholder.c, too, so planning in such cases should be a bit faster.

Issue noted while pursuing bugs reported by Jeremy Evans and Antonin
Houska, though this doesn't in itself fix either of their reported cases.
What this does do is prevent an Assert crash in the kind of query
illustrated by the added regression test.  (I'm not sure that the plan for
that query is stable enough across platforms to be usable as a regression
test output ... but we'll soon find out from the buildfarm.)

Back-patch to 9.3.  The problem case can't arise without LATERAL, so
no need to touch older branches.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/1b1d3d92c3ec1179c65756f60a1eb477793488ea

Modified Files
--------------
src/backend/nodes/copyfuncs.c             |    1 -
src/backend/nodes/equalfuncs.c            |    1 -
src/backend/nodes/outfuncs.c              |    1 -
src/backend/optimizer/plan/analyzejoins.c |    2 -
src/backend/optimizer/plan/initsplan.c    |   36 +++------
src/backend/optimizer/util/placeholder.c  |  114 +++++++----------------------
src/include/nodes/relation.h              |   16 +---
src/include/optimizer/placeholder.h       |    2 -
src/test/regress/expected/join.out        |   52 +++++++++++++
src/test/regress/sql/join.sql             |   13 ++++
10 files changed, 103 insertions(+), 135 deletions(-)


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: docs: document TRIM "comma" syntax
Next
From: Tom Lane
Date:
Subject: pgsql: Remove ph_may_need from PlaceHolderInfo, with attendant simplifi