Re: INSERT ... ON CONFLICT syntax issues

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

On Wed, May 6, 2015 at 2:01 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> How about
> 6. The tablename and EXCLUDED? Possibility with the ability to specify
> an AS for INSERT INTO foo AS whatever?
>
> From an implementation pov that'd be simple ;)

That's what I wanted to do when I realized what Andres wanted to do
with the TARGET alias. Clearly that would compel us to actually make
the RETURNING clause buy into this alias, just as with a regular
UPDATE. And not having the alias on the target also be magical seems
like a good thing. Nothing can be broken by this scheme. No?

>> NEW and OLD are pretty good. Like in an UPDATE trigger, NEW refers to the
>> version after the UPDATE, and OLD to the version before. However, there's
>> the serious problem that in a trigger function, OLD/NEW are already in use.
>> How bad is that? At least in PL/pgSQL you can work around it by aliasing the
>> variables, but it's a bit inconvenient. How often would INSERT .. ON
>> CONFLICT DO UPDATE be used in a trigger?
>
> I personally think it's a killer. It'll be very annoying to understand
> mistaken usage of NEW/OLD in that case.

+1

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-05-06 21:10:22 Re: INSERT ... ON CONFLICT syntax issues
Previous Message Andres Freund 2015-05-06 21:01:42 Re: INSERT ... ON CONFLICT syntax issues