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-00000001dSQ-31P5@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_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0c45929db4825843f5ac2c0a54a65b90a9a541fd
Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
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-00000001dSQ-31P5@gemulon.postgresql.org>
References: <E1xH4nJ-00000001dSQ-31P5@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