Re: INSERT ... ON CONFLICT syntax issues

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: INSERT ... ON CONFLICT syntax issues
Дата
Msg-id CAM3SWZQHSj1FA69grqRsu0Pq-vXJAVhsHu-ZtxCYOyik39SDAQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: INSERT ... ON CONFLICT syntax issues  (Stephen Frost <sfrost@snowman.net>)
Ответы Re: INSERT ... ON CONFLICT syntax issues  (Stephen Frost <sfrost@snowman.net>)
Список pgsql-hackers
On Sun, Apr 26, 2015 at 11:08 AM, Stephen Frost <sfrost@snowman.net> wrote:
>> I don't want to accept something that automatically merges the
>> excluded tuple (e.g., "SET (*) = EXLCUDED.*"), for reasons outlined
>> here: https://wiki.postgresql.org/wiki/UPSERT#VoltDB.27s_UPSERT
>
> Perhaps I'm missing it, but the reasons that I see there appear to be:
>
> "It'd be like SELECT *" and "we'd have to decide what to do about the
> value for unspecified columns".  As for the latter- we have to do that
> *anyway*, no?  What happens if you do:
>
> INSERT INTO mytable (foo, bar, baz, bat) VALUES ('key1','key2','val1','val2')
> ON CONFLICT (foo) UPDATE SET (baz) = (EXCLUDED.baz);
>
> ?

It's like any other UPDATE - the values of columns not appearing in
the targetlist are unchanged from the original row version now
superseded. It doesn't matter that you had some other values in the
INSERT. You only get what you ask for.

-- 
Peter Geoghegan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Fwd: [GENERAL] 4B row limit for CLOB tables
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: PATCH: default_index_tablespace