postgresql/src/include/optimizer
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
..
appendinfo.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
clauses.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
cost.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_copy.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_gene.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_misc.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_mutation.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_pool.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_random.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_recombination.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geqo_selection.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
inherit.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
joininfo.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
optimizer.h Rename force_parallel_mode to debug_parallel_query 2023-02-15 21:21:59 +13:00
orclauses.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
paramassign.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pathnode.h Fix some issues with improper placement of outer join clauses. 2023-05-17 11:14:04 -04:00
paths.h Fix some issues with improper placement of outer join clauses. 2023-05-17 11:14:04 -04:00
placeholder.h Do assorted mop-up in the planner. 2023-01-30 13:44:36 -05:00
plancat.h Fix calculation of which GENERATED columns need to be updated. 2023-01-05 14:12:17 -05:00
planmain.h Invent "join domains" to replace the below_outer_join hack. 2023-01-30 13:50:25 -05:00
planner.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
prep.h Make Vars be outer-join-aware. 2023-01-30 13:16:20 -05:00
restrictinfo.h Do assorted mop-up in the planner. 2023-01-30 13:44:36 -05:00
subselect.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
tlist.h Update copyright for 2023 2023-01-02 15:00:37 -05:00