Re: INSERT ... ON CONFLICT syntax issues - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: INSERT ... ON CONFLICT syntax issues
Date
Msg-id CAM3SWZRf5R6d2Dp=O76XCR7hJt3GU9E6Kt5_J1b5=StXMFh_Fw@mail.gmail.com
Whole thread Raw
In response to Re: INSERT ... ON CONFLICT syntax issues  (Peter Geoghegan <pg@heroku.com>)
List pgsql-hackers
On Sat, Apr 25, 2015 at 11:50 AM, Peter Geoghegan <pg@heroku.com> wrote:
> To be fair, there is one unrelated slight difference with RETURNING
> and conventional UPDATEs: You cannot return the EXCLUDED tuple (in the
> same way that you can reference the joined-FROM tuple within
> conventional UPDATEs). This is because the pertinent information is
> likely to be in the target tuple (after all, the DML statement names
> the proposed-for-insertion tuples itself, directly), but more
> importantly because projecting both would necessitate *always*
> qualifying the RETURNING column names to resolve which tuple is
> intended (UPDATE FROM will seldom be a self-join, but this will always
> be like a self-join).


It also makes sense because this is the RETURNING clause of an INSERT,
not an UPDATE. So the general INSERT behavior is what is expected. It
ought to be irrelevant if tuples were projected by actually inserting
or updating. Otherwise, your UPSERT is probably misconceived.

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: INSERT ... ON CONFLICT syntax issues
Next
From: Andres Freund
Date:
Subject: Re: INSERT ... ON CONFLICT syntax issues