pgsql: Further adjustments to PlaceHolderVar removal.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Further adjustments to PlaceHolderVar removal.
Дата
Msg-id E1ZNm9d-0003Ju-KS@gemulon.postgresql.org
обсуждение исходный текст
Список 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_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/085338822a2364b5d3afbb13c635b00df43ade45

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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Further adjustments to PlaceHolderVar removal.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Further adjustments to PlaceHolderVar removal.