postgresql/src/backend/optimizer/path
Tom Lane 9df8f903eb Fix some issues with improper placement of outer join clauses.
After applying outer-join identity 3 in the forward direction,
it was possible for the planner to mistakenly apply a qual clause
from above the two outer joins at the now-lower join level.
This can give the wrong answer, since a value that would get nulled
by the now-upper join might not yet be null.

To fix, when we perform such a transformation, consider that the
now-lower join hasn't really completed the outer join it's nominally
responsible for and thus its relid set should not include that OJ's
relid (nor should its output Vars have that nullingrel bit set).
Instead we add those bits when the now-upper join is performed.
The existing rules for qual placement then suffice to prevent
higher qual clauses from dropping below the now-upper join.
There are a few complications from needing to consider transitive
closures in case multiple pushdowns have happened, but all in all
it's not a very complex patch.

This is all new logic (from 2489d76c4) so no need to back-patch.
The added test cases all have the same results as in v15.

Tom Lane and Richard Guo

Discussion: https://postgr.es/m/0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru
2023-05-17 11:14:04 -04:00
..
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
allpaths.c Fix some typos and some incorrectly duplicated words 2023-04-18 14:03:49 +12:00
clausesel.c Do assorted mop-up in the planner. 2023-01-30 13:44:36 -05:00
costsize.c Fix some issues with improper placement of outer join clauses. 2023-05-17 11:14:04 -04:00
equivclass.c Fix some issues with improper placement of outer join clauses. 2023-05-17 11:14:04 -04:00
indxpath.c Fix some issues with improper placement of outer join clauses. 2023-05-17 11:14:04 -04:00
joinpath.c Support "Right Anti Join" plan shapes. 2023-04-05 16:59:09 -04:00
joinrels.c Fix some issues with improper placement of outer join clauses. 2023-05-17 11:14:04 -04:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
pathkeys.c Support "Right Anti Join" plan shapes. 2023-04-05 16:59:09 -04:00
tidpath.c Make Vars be outer-join-aware. 2023-01-30 13:16:20 -05:00