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: Fix infer_arbiter_indexes() to not assume resultRelation is 1.
Date: Tue, 11 Jun 2024 21:58:15 +0000
Message-ID: <E1sH9VO-0016io-Jg@gemulon.postgresql.org> (raw)

Fix infer_arbiter_indexes() to not assume resultRelation is 1.

infer_arbiter_indexes failed to renumber varnos in index expressions
or predicates that it got from the catalogs.  This escaped detection
up to now because the stored varnos in such trees will be 1, and an
INSERT's result relation is usually the first rangetable entry,
so that that was fine.  However, in cases such as inserting through
an updatable view, it's not fine, leading to failure to match the
expressions to the query with ensuing "there is no unique or exclusion
constraint matching the ON CONFLICT specification" errors.

Fix by copy-and-paste from get_relation_info().

Per bug #18502 from Michael Wang.  Back-patch to all supported
versions.

Discussion: https://postgr.es/m/18502-545b53f5b81e54e0@postgresql.org

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/096f2132c66c9e267999707b3d83482749748520

Modified Files
--------------
src/backend/optimizer/util/plancat.c          |  9 ++++++++-
src/test/regress/expected/insert_conflict.out | 13 +++++++++++++
src/test/regress/sql/insert_conflict.sql      |  6 ++++++
3 files changed, 27 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1sH9VO-0016io-Jg@gemulon.postgresql.org>
Permalink:  ../E1sH9VO-0016io-Jg@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sH9VO-0016io-Jg@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: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix infer_arbiter_indexes() to not assume resultRelation is 1.
  In-Reply-To: <E1sH9VO-0016io-Jg@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