pgsql: Fix calculation of relid sets for partitionwise child joins.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix calculation of relid sets for partitionwise child joins.
Date: 2023-07-21 16:00:22
Message-ID: E1qMsYH-000dLa-I4@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2023-07-21 22:50:10 pgsql: ICU: remove negative test that fails to fail.
Previous Message Amit Langote 2023-07-21 10:29:37 pgsql: Code review for commit b6e1157e7d