Re: INSERT ... ON CONFLICT syntax issues

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: INSERT ... ON CONFLICT syntax issues
Дата
Msg-id CAM3SWZSGr7v7c=0M2Hh1nSaLD9dN83YvohzV0OBs7LbGF+mX8A@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 6:34 AM, Stephen Frost <sfrost@snowman.net> wrote:
> What's important, in my view, is to keep the simple case simple and so
> I'm not particularly wedded to any of these approaches, just trying to
> help with other suggestions.
>
> INSERT INTO mytable VALUES ('key1','key2','val1','val2')
> ON CONFLICT UPDATE SET val1 = 'val1', val2 = 'val2';
>
> strikes me as a the 99% use-case here that we need to keep sane, and
> it'd be really nice if we didn't have to include the SET clause and
> duplicate those values at all..  That could be something we add later
> though, I don't think it needs to be done now.

You can do that already. That's what the EXCLUDED.* alias that is
automatically added is for (the thing that Andres disliked the
spelling of - or the other thing). This is legal, for example:

INSERT INTO mytable (foo, bar, baz, bat) VALUES ('key1','key2','val1','val2')
ON CONFLICT (foo) UPDATE SET (foo, bar, baz, bat) = (EXCLUDED.foo,
EXCLUDED.bar, EXCLUDED.baz, EXCLUDED.bat)';

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
-- 
Peter Geoghegan



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: fix typos in comments
Следующее
От: Euler Taveira
Дата:
Сообщение: Re: parallel mode and parallel contexts