pgsql: Fix joinclause removal logic to cope with cloned clauses.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix joinclause removal logic to cope with cloned clauses.
Дата
Msg-id E1q2a4E-001qcA-2E@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix joinclause removal logic to cope with cloned clauses.

When we're deleting a no-op LEFT JOIN from the query, we must remove
the join's joinclauses from surviving relations' joininfo lists.
The invention of "cloned" clauses in 2489d76c4 broke the logic for
that; it'd fail to remove clones that include OJ relids outside the
doomed join's min relid sets, which could happen if that join was
previously discovered to commute with some other join.

This accidentally failed to cause problems in the majority of cases,
because we'd never decide that such a cloned clause was evaluatable at
any surviving join.  However, Richard Guo discovered a case where that
did happen, leading to "no relation entry for relid" errors later.
Also, adding assertions that a non-removed clause contains no Vars from
the doomed join exposes that there are quite a few existing regression
test cases where the problem happens but is accidentally not exposed.

The fix for this is just to include the target join's commute_above_r
and commute_below_l sets in the relid set we test against when
deciding whether a join clause is "pushed down" and thus not
removable.

While at it, do a little refactoring: the join's relid set can be
computed inside remove_rel_from_query rather than in the caller.

Patch by me; thanks to Richard Guo for review.

Discussion: https://postgr.es/m/CAMbWs4_PHrRqTKDNnTRsxxQy6BtYCVKsgXm1_gdN2yQ=kmcO5g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7a844c77ece1bda3b076034bc20142d4bd66db7a

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 91 ++++++++++++++++++++-----------
src/test/regress/expected/join.out        | 16 ++++++
src/test/regress/sql/join.sql             |  6 ++
3 files changed, 82 insertions(+), 31 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Jeff Davis
Дата:
Сообщение: pgsql: Doc fixes for commit 1e16af8ab5.
Следующее
От: Jeff Davis
Дата:
Сообщение: pgsql: ICU: use uloc_getDefault() for initdb.