pgsql: Use PlaceHolderVars within the quals of a FULL JOIN.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Use PlaceHolderVars within the quals of a FULL JOIN.
Дата
Msg-id E1gBjrm-0002cy-Cp@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Use PlaceHolderVars within the quals of a FULL JOIN.

This prevents failures in cases where we pull up a constant or var-free
expression from a subquery and put it into a full join's qual.  That can
result in not recognizing the qual as containing a mergejoin-able or
hashjoin-able condition.  A PHV prevents the problem because it is still
recognized as belonging to the side of the join the subquery is in.

I'm not very sure about the net effect of this change on plan quality.
In "typical" cases where the join keys are Vars, nothing changes.
In an affected case, the PHV-wrapped expression is less likely to be seen
as equal to PHV-less instances below the join, but more likely to be seen
as equal to similar expressions above the join, so it may end up being a
wash.  In the one existing case where there's any visible change in a
regression-test plan, it amounts to referencing a lower computation of a
COALESCE result instead of recomputing it, which seems like a win.

Given my uncertainty about that and the lack of field complaints,
no back-patch, even though this is a very ancient problem.

Discussion: https://postgr.es/m/32090.1539378124@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 12 ++++++++++++
src/test/regress/expected/join.out        | 16 +++++++++++++++-
src/test/regress/sql/join.sql             |  7 +++++++
3 files changed, 34 insertions(+), 1 deletion(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Clean up/tighten up coercibility checks in opr_sanityregression
Следующее
От: Andres Freund
Дата:
Сообщение: Re: pgsql: Avoid duplicate XIDs at recovery when building initialsnapshot