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 join removal logic to clean up sub-RestrictInfos of OR claus
Date: Fri, 10 Feb 2023 19:52:42 +0000
Message-ID: <E1pQZRp-000Ra1-Sn@gemulon.postgresql.org> (raw)

Fix join removal logic to clean up sub-RestrictInfos of OR clauses.

analyzejoins.c took care to clean out removed relids from the
clause_relids and required_relids of RestrictInfos associated with
the doomed rel ... but it paid no attention to the fact that if such a
RestrictInfo contains an OR clause, there will be sub-RestrictInfos
containing similar fields.

I'm more than a bit surprised that this oversight hasn't caused
visible problems before.  In any case, it's certainly broken now,
so add logic to clean out the sub-RestrictInfos recursively.
We might need to back-patch this someday.

Per bug #17786 from Robins Tharakan.

Discussion: https://postgr.es/m/17786-f1ea7fbdab97daec@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/44e56baa80ff5fba150897308c8f25aa2251b16c

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 77 +++++++++++++++++++++++++------
src/test/regress/expected/join.out        | 20 ++++++++
src/test/regress/sql/join.sql             |  8 ++++
3 files changed, 90 insertions(+), 15 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1pQZRp-000Ra1-Sn@gemulon.postgresql.org>
Permalink:  ../E1pQZRp-000Ra1-Sn@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pQZRp-000Ra1-Sn@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 join removal logic to clean up sub-RestrictInfos of OR claus
  In-Reply-To: <E1pQZRp-000Ra1-Sn@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