pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix possible usage of incorrect UPPERREL_SETOP RelOptInfo
Date: Tue, 04 Nov 2025 22:48:31 +0000
Message-ID: <E1vGPpH-0053iF-0S@gemulon.postgresql.org> (raw)

Fix possible usage of incorrect UPPERREL_SETOP RelOptInfo

03d40e4b5 allowed dummy UNION [ALL] children to be removed from the plan
by checking for is_dummy_rel().  That commit neglected to still account
for the relids from the dummy rel so that the correct UPPERREL_SETOP
RelOptInfo could be found and used for adding the Paths to.

Not doing this could result in processing of subsequent UNIONs using the
same RelOptInfo as a previously processed UNION, which could result in
add_path() freeing old Paths that are needed by the previous UNION.

The same fix was independently submitted (2 mins later) by Richard Guo.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/bee34aec-659c-46f1-9ab7-7bbae0b7616c@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fdda78e361f136ec2b8de579b366c1e66bba1199

Modified Files
--------------
src/backend/optimizer/prep/prepunion.c | 8 ++++++--
src/test/regress/expected/union.out    | 6 +++---
2 files changed, 9 insertions(+), 5 deletions(-)



Message-ID: <E1vGPpH-0053iF-0S@gemulon.postgresql.org>
Permalink:  ../E1vGPpH-0053iF-0S@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vGPpH-0053iF-0S@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: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix possible usage of incorrect UPPERREL_SETOP RelOptInfo
  In-Reply-To: <E1vGPpH-0053iF-0S@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