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 20:00:02
Message-ID: CAM3SWZQ7mHV6uut-T0KgNXT2_5xNWM1Skd01XQvjdh_WsZB+tw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 25, 2015 at 12:35 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
>>> > That
>>> > it has 'morphing' characteristics imo just makes it worse, rather than
>>> > better. Besides being confusing that it has different meanings, it's far
>>> > from inconceivable that somebody wants to return values from the
>>> > preexisting, new, and merged rows.
>>>
>>> This is how RETURNING works from UPDATEs in general.
>>
>> And there's been a patch (which unfortunately died because it's
>> implementation wasn't good), to allow referring to the other versions of
>> the tuple. It has been wished for numerous times.
>
> Well, if that patch is ever committed, then it won't be hard to get
> the behavior here too, since it is literally exactly the same code. I
> don't change anything about it, and that seems to be your problem.

I withdraw this remark. Even in a world where this patch is committed,
it still makes sense for the INSERT returning behavior to not be
altered (and to project only TARGET tuples even if they come from the
auxiliary UPDATE). The "join" is within the auxiliary UPDATE, not the
INSERT, and it should be no more possible to project intermediate
tuples (like EXCLUDED.*) from the INSERT's RETURNING than it is to
project CTE scan tuples from an INSERT ... RETURNING with a CTE.

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-04-25 20:18:25 Re: Bug in planner
Previous Message Peter Geoghegan 2015-04-25 19:35:12 Re: INSERT ... ON CONFLICT syntax issues