pgsql: Fix semijoin unique-ification for child relations

From: Richard Guo <rguo(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix semijoin unique-ification for child relations
Date: 2025-08-29 04:14:40
Message-ID: E1urqVb-002Aki-2w@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix semijoin unique-ification for child relations

For a child relation, we should not assume that its parent's
unique-ified relation (or unique-ified path in v18) always exists. In
cases where all RHS columns that need to be unique-ified are equated
to constants, the unique-ified relation/path for the parent table is
not built, as there are no columns left to unique-ify. Failing to
account for this can result in a SIGSEGV crash during planning.

This patch checks whether the parent's unique-ified relation or path
exists and skips unique-ification of the child relation if it does
not.

Author: Richard Guo <guofenglinux(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAMbWs49MOdLW2c+qbLHHBt8VBu=4ONpM91D19=AWeW93eFUF6A@mail.gmail.com
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/97b0f36bde9a08bc6f004438ff8fc0afbcb418c0

Modified Files
--------------
src/backend/optimizer/plan/planner.c | 9 ++++++
src/test/regress/expected/join.out | 60 ++++++++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 37 ++++++++++++++++++++++
3 files changed, 106 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Richard Guo 2025-08-29 04:17:17 pgsql: Fix semijoin unique-ification for child relations
Previous Message Masahiko Sawada 2025-08-29 00:08:00 pgsql: Use LW_SHARED in walsummarizer.c for WALSummarizerLock lock wher