Re: INSERT ... ON CONFLICT syntax issues

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Subject: Re: INSERT ... ON CONFLICT syntax issues
Date: 2015-04-25 18:54:21
Message-ID: CAM3SWZRf5R6d2Dp=O76XCR7hJt3GU9E6Kt5_J1b5=StXMFh_Fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 25, 2015 at 11:50 AM, Peter Geoghegan <pg(at)heroku(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-04-25 19:23:25 Re: INSERT ... ON CONFLICT syntax issues
Previous Message Peter Geoghegan 2015-04-25 18:50:59 Re: INSERT ... ON CONFLICT syntax issues