pgsql: Fix misuse of RelOptInfo.unique_for_rels cache by SJE

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix misuse of RelOptInfo.unique_for_rels cache by SJE
Date: 2024-01-08 22:09:21
Message-ID: E1rMxo9-000WzQ-Va@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix misuse of RelOptInfo.unique_for_rels cache by SJE

When SJE uses RelOptInfo.unique_for_rels cache, it passes filtered quals to
innerrel_is_unique_ext(). That might lead to an invalid match to cache entries
made by previous non self-join checking calls. Add UniqueRelInfo.self_join
flag to prevent such cases. Also, fix that SJE should require a strict match
of outerrelids to make sure UniqueRelInfo.extra_clauses are valid.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/4788f781-31bd-9796-d7d6-588a751c8787%40gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/30b4955a4668887044568743debef804b14418ca

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 30 +++++++++++++++++++++---------
src/include/nodes/pathnodes.h | 6 ++++++
src/test/regress/expected/join.out | 23 +++++++++++++++++++++++
src/test/regress/sql/join.sql | 9 +++++++++
4 files changed, 59 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2024-01-09 08:02:42 pgsql: Forbid SJE with result relation
Previous Message Noah Misch 2024-01-08 19:41:28 pgsql: Make dblink interruptible, via new libpqsrv APIs.