From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(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-07 12:02:59 |
Message-ID: | 554B5473.2000107@iki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 05/07/2015 12:01 AM, Andres Freund 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 ;)
I did this, because as you say it's simple to implement, and it resolves
the problem with RETURNING.
BTW, it's worth noting that the <tablename>.col (or TARGET.col before)
means different things in the DO UPDATE clause, and in RETURNING.
Consider this example:
postgres=# create table foo (id int4 primary key, t text);
CREATE TABLE
postgres=# insert into foo values (1, 'original');
INSERT 0 1
postgres=# insert into foo values (1, 'inserted') on conflict (id) do
update set t = excluded.t || foo.t returning foo.t;
t
------------------
insertedoriginal
(1 row)
In the DO UPDATE, foo.t was 'original', but in the RETURNING, it was
'insertedoriginal'. That's what I was thinking yesterday, when I said
that it's not straightforward to just replace "target" with
"<tablename>", but got confused. This isn't new, however; it works the
same in a normal UPDATE RETURNING.
- Heikki
From | Date | Subject | |
---|---|---|---|
Next Message | Sawada Masahiko | 2015-05-07 12:05:55 | Proposal : REINDEX xxx VERBOSE |
Previous Message | Alvaro Herrera | 2015-05-07 11:43:45 | Re: is possible to upgrade from 9.2 to 9.4 with pg_upgrade |