[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-hackers
Subject:    Re: doc: Clarify what "excluded" represents for INSERT ON CONFLICT
From:       Peter Geoghegan <pg () bowt ! ie>
Date:       2022-06-30 22:40:23
Message-ID: CAH2-Wz=O1=_DCzPCLtjgnh6n=Lwsr-vVv4Ddhd7sQ4yiYgPKHw () mail ! gmail ! com
[Download RAW message or body]

On Thu, Jun 30, 2022 at 3:07 PM David G. Johnston
<david.g.johnston@gmail.com> wrote:
> Yes, and based on a single encounter I agree this doesn't seem like a bro=
adly encountered issue.  My takeaway from that eventually led to this propo=
sal.  The "Other Person" who is complaining about the docs is one of the me=
ntors on the Discord server and works for one of the corporate contributors=
 to the community. (I suppose Discord is considered public so maybe this re=
daction is unnecessary...)

My impression from reading this transcript is that the user was
confused as to why they needed to qualify the target table name in the
ON CONFLICT DO UPDATE's WHERE clause -- they didn't have to qualify it
in the targetlist that appears in "SET ... ", so why the need to do it
in the WHERE clause? This isn't something that upsert statements need
to do all that often, just because adding additional conditions to the
WHERE clause isn't usually necessary. That much makes sense to me -- I
*can* imagine how that could cause confusion.

If that interpretation is correct, then it's not clear what it should
mean for how the INSERT documentation describes EXCLUDED. EXCLUDED is
involved here, since EXCLUDED is the thing that creates the ambiguity,
but that seems almost incidental to me. This user would probably not
have been confused if they didn't need to use a WHERE clause (very
much the common case), even when expression evaluation involving
EXCLUDED in the SET was still used (also common).

--
Peter Geoghegan


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic