pgsql: Fix calculation of relid sets for partitionwise child joins. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix calculation of relid sets for partitionwise child joins.
Date
Msg-id E1qMsYH-000dLa-I4@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix calculation of relid sets for partitionwise child joins.

Applying add_outer_joins_to_relids() to a child join doesn't actually
work, even if we've built a SpecialJoinInfo specialized to the child,
because that function will also compare the join's relids to elements
of the main join_info_list, which only deal in regular relids not
child relids.  This mistake escaped detection by the existing
partitionwise join tests because they didn't test any cases where
add_outer_joins_to_relids() needs to add additional OJ relids (that
is, any cases where join reordering per identity 3 is possible).

Instead, let's apply adjust_child_relids() to the relids of the parent
join.  This requires minor code reordering to collect the relevant
AppendRelInfo structures first, but that's work we'd do shortly anyway.

Report and fix by Richard Guo; cosmetic changes by me

Discussion: https://postgr.es/m/CAMbWs49NCNbyubZWgci3o=_OTY=snCfAPtMnM-32f3mm-K-Ckw@mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f75595cd80d134d5a63929a90a0347ff9729b79a

Modified Files
--------------
src/backend/optimizer/path/joinrels.c        | 14 +++++----
src/backend/optimizer/util/relnode.c         | 18 +++++++----
src/test/regress/expected/partition_join.out | 46 ++++++++++++++++++++++++++++
src/test/regress/sql/partition_join.sql      |  9 ++++++
4 files changed, 75 insertions(+), 12 deletions(-)


pgsql-committers by date:

Previous
From: Amit Langote
Date:
Subject: pgsql: Code review for commit b6e1157e7d
Next
From: Jeff Davis
Date:
Subject: pgsql: ICU: remove negative test that fails to fail.