From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow table-qualified variable names in ON CONFLICT ... WHERE.
Date: Tue, 13 Apr 2021 19:39:49 +0000
Message-ID: <E1lWOt3-0001aA-FJ@gemulon.postgresql.org> (raw)
Allow table-qualified variable names in ON CONFLICT ... WHERE.
Previously you could only use unqualified variable names here.
While that's not a functional deficiency, since only the target
table can be referenced, it's a surprising inconsistency with the
rules for partial-index predicates, on which this syntax is
supposedly modeled.
The fix for that is no harder than passing addToRelNameSpace = true
to addNSItemToQuery. However, it's really pretty bogus for
transformOnConflictArbiter and transformOnConflictClause to be
messing with the namespace item for the target table at all.
It's not theirs to manage, it results in duplicative creations of
namespace items, and transformOnConflictClause wasn't even doing
it quite correctly (that coding resulted in two nsitems for the
target table, since it hadn't cleaned out the existing one).
Hence, make transformInsertStmt responsible for setting up the
target nsitem once for both these clauses and RETURNING.
Also, arrange for ON CONFLICT ... UPDATE's "excluded" pseudo-relation
to be added to the rangetable before we run transformOnConflictArbiter.
This produces a more helpful HINT if someone writes "excluded.col"
in the arbiter expression.
Per bug #16958 from Lukas Eder. Although I agree this is a bug,
the consequences are hardly severe, so no back-patch.
Discussion: https://postgr.es/m/16958-963f638020de271c@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6c0373ab77359c94b279c4e67c91aa623841af65
Modified Files
--------------
src/backend/parser/analyze.c | 81 ++++++++++++++++-----------
src/backend/parser/parse_clause.c | 13 -----
src/test/regress/expected/insert_conflict.out | 4 +-
src/test/regress/sql/insert_conflict.sql | 2 +-
4 files changed, 52 insertions(+), 48 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Allow table-qualified variable names in ON CONFLICT ... WHERE.
In-Reply-To: <E1lWOt3-0001aA-FJ@gemulon.postgresql.org>
References: <E1lWOt3-0001aA-FJ@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