Re: UPSERT/RETURNING -> ON CONFLICT SELECT?

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Bjørnar Ness <bjornar(dot)ness(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: UPSERT/RETURNING -> ON CONFLICT SELECT?
Date: 2016-07-13 17:02:11
Message-ID: CAM3SWZQwAT1=zfzFKC49sNhY9XSK9h7C10r2w1sOZ8YgNRpdxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 13, 2016 at 2:49 AM, Bjørnar Ness <bjornar(dot)ness(at)gmail(dot)com> wrote:
> But with upsert/do nothing, this will not work as "needed".
>
> Would it be possible to introduce a "ON CONFLICT SELECT" argument:
>
> with _foo as (
> insert into foo(i) values(1)
> on conflict select returning id
> ) insert into bar(foo_id,i)
> select id,2 from _foo;

I gather that the point of this pseudo SQL is to show how you might be
able to project and select the values not successfully inserted. Can't
you just pipeline together some CTEs instead?

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-07-13 17:07:39 Re: application_name in process name?
Previous Message Tom Lane 2016-07-13 17:01:55 Re: Showing parallel status in \df+