postgresql/src/include/optimizer
Tom Lane 739f1d6218 Fix mis-handling of outer join quals generated by EquivalenceClasses.
It's possible, in admittedly-rather-contrived cases, for an eclass
to generate a derived "join" qual that constrains the post-outer-join
value(s) of some RHS variable(s) without mentioning the LHS at all.
While the mechanisms were set up to work for this, we fell foul of
the "get_common_eclass_indexes" filter installed by commit 3373c7155:
it could decide that such an eclass wasn't relevant to the join, so
that the required qual clause wouldn't get emitted there or anywhere
else.

To fix, apply get_common_eclass_indexes only at inner joins, where
its rule is still valid.  At an outer join, fall back to examining all
eclasses that mention either input (or the OJ relid, though it should
be impossible for an eclass to mention that without mentioning either
input).  Perhaps we can improve on that later, but the cost/benefit of
adding more complexity to skip some irrelevant eclasses is dubious.

To allow cheaply distinguishing outer from inner joins, pass the
ojrelid to generate_join_implied_equalities as a separate argument.
This also allows cleaning up some sloppiness that had crept into
the definition of its join_relids argument, and it allows accurate
calculation of nominal_join_relids for a child outer join.  (The
latter oversight seems not to have been a live bug, but it certainly
could have caused problems in future.)

Also fix what might be a live bug in check_index_predicates: it was
being sloppy about what it passed to generate_join_implied_equalities.

Per report from Richard Guo.

Discussion: https://postgr.es/m/CAMbWs4-DsTBfOvXuw64GdFss2=M5cwtEhY=0DCS7t2gT7P6hSA@mail.gmail.com
2023-02-23 11:05:58 -05: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 Make Vars be outer-join-aware. 2023-01-30 13:16:20 -05:00
paths.h Fix mis-handling of outer join quals generated by EquivalenceClasses. 2023-02-23 11:05:58 -05: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