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

From Andres Freund
Subject Re: INSERT ... ON CONFLICT syntax issues
Date
Msg-id 20150506210142.GE12506@alap3.anarazel.de
Whole thread Raw
In response to Re: INSERT ... ON CONFLICT syntax issues  (Heikki Linnakangas <hlinnaka@iki.fi>)
Responses Re: INSERT ... ON CONFLICT syntax issues  (Peter Geoghegan <pg@heroku.com>)
Re: INSERT ... ON CONFLICT syntax issues  (Heikki Linnakangas <hlinnaka@iki.fi>)
Re: INSERT ... ON CONFLICT syntax issues  (Heikki Linnakangas <hlinnaka@iki.fi>)
Re: INSERT ... ON CONFLICT syntax issues  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
On 2015-05-06 23:48:18 +0300, Heikki Linnakangas wrote:
> I'll see about fixing that. It's not just a matter of creating another alias
> for the same rel, I'm afraid: "foo.t" is supposed to refer to the tuple that
> we attempted to insert, like it does without the ON CONFLICT.

I'm not sure what you mean here?

> But actually, I don't much like the "target" alias in the first place. We
> never really completed this discussion, everyone just got tired:

Right. But that doesn't affect the "it's not just a matter of ..." bit
above, right?

> Reading through this sub-thread, these spellings have been proposed:
> 
> 1. TARGET and EXCLUDED
> 
> 2. NEW and EXISTING
> 
> 3. NEW and OLD
> 
> 4. PROPOSED and EXISTING
> 
> 5. CONFLICTING and EXISTING
> 
> Did I miss any? Now, let me opine on these.

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 ;)

> 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.

Greetings,

Andres Freund



pgsql-hackers by date:

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