]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix infer_arbiter_indexes() to not assume resultRelation is 1.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Jun 2024 21:57:46 +0000 (17:57 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 11 Jun 2024 21:57:46 +0000 (17:57 -0400)
commitb188e1bf75760fed76406a48c81bcd8ac6a8fda9
treec4a4b4e5227ab06684a69d3fbe32960c7d5753c6
parentbf78abebf3e5c827a48186b2b1388c691e16fafc
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
src/backend/optimizer/util/plancat.c
src/test/regress/expected/insert_conflict.out
src/test/regress/sql/insert_conflict.sql