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: Clear more substructure of a dead relation during join removal.
Date: Wed, 14 Oct 2026 19:37:45 +0000
Message-ID: <E1xH4nJ-00000001dSU-3DqV@gemulon.postgresql.org> (raw)

Clear more substructure of a dead relation during join removal.

The tablesample and securityQuals subtrees of a RangeTblEntry can
include Vars, which will cause trouble if they point at a removed
rel and are visited during later processing.  Hence, clear those
fields during join removal, as we already do for the subquery field.
remove_useless_outer_joins got this right for securityQuals but
not tablesample, while remove_self_join_rel missed doing it for
securityQuals.  (It escapes trouble for tablesample only because we
made a policy decision to never touch sampled relations for SJE.)

Oversight in 2ebf25e7d.  Back-patch to v16, like that commit
(but the SJE issue only goes as far back as v18).

Author: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAGRkXqSOAT1yop44B8jwacL_91rxK=QuoU8Of3NLMb9NgAO2NA@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/12f10c25ce3febf9b94748d28c8332f827779980

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1xH4nJ-00000001dSU-3DqV@gemulon.postgresql.org>
Permalink:  ../E1xH4nJ-00000001dSU-3DqV@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xH4nJ-00000001dSU-3DqV@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Clear more substructure of a dead relation during join removal.
  In-Reply-To: <E1xH4nJ-00000001dSU-3DqV@gemulon.postgresql.org>
  References: <E1xH4nJ-00000001dSU-3DqV@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