Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}

Поиск
Список
Период
Сортировка
От Andreas Karlsson
Тема Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Дата
Msg-id 546D45F3.10802@proxel.se
обсуждение исходный текст
Ответ на Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}  (Peter Geoghegan <pg@heroku.com>)
Ответы Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}  (Peter Geoghegan <pg@heroku.com>)
Список 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 по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: New Event Trigger: table_rewrite
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}