pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix calculation of relid sets for partitionwise child joins.
Date: Fri, 21 Jul 2023 16:00:22 +0000
Message-ID: <E1qMsYH-000dLa-I4@gemulon.postgresql.org> (raw)

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(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1qMsYH-000dLa-I4@gemulon.postgresql.org>
Permalink:  ../E1qMsYH-000dLa-I4@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qMsYH-000dLa-I4@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix calculation of relid sets for partitionwise child joins.
  In-Reply-To: <E1qMsYH-000dLa-I4@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox