Re: INSERT ... ON CONFLICT {UPDATE | IGNORE} - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Date
Msg-id 546D45F3.10802@proxel.se
Whole thread Raw
In response to Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}  (Peter Geoghegan <pg@heroku.com>)
Responses Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}  (Peter Geoghegan <pg@heroku.com>)
List pgsql-hackers
On 11/20/2014 01:52 AM, Peter Geoghegan wrote:
> On Mon, Nov 10, 2014 at 3:33 PM, Peter Geoghegan <pg@heroku.com> wrote:
> Also, I think someone else mentioned this a few months back.

Yeah, that was me.

I think we have three options.

1. Return only inserted tuples
2. Return inserted and updated tuples
3. Return inserted, updated and skipped tuples

To me option 1 is surprising and less useful since I imagine in most 
cases where you do an upsert you do not care if the tuple was inserted 
or updated as long as it has the right values after the upsert, and 
these values is also what I would expect to be returned.

The possible use case I see for option 3 is when you want the values of 
automatically generated columns but there is actually no work to do if 
another transaction had already inserted the same row (same according to 
the unique constraints). But this behavior even though useful in certain 
cases might be surprising.

Andreas




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: New Event Trigger: table_rewrite
Next
From: Peter Geoghegan
Date:
Subject: Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}