From: | Peter Geoghegan <pg(at)heroku(dot)com> |
---|---|
To: | Stephen Frost <sfrost(at)snowman(dot)net> |
Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
Subject: | Re: INSERT ... ON CONFLICT syntax issues |
Date: | 2015-04-26 17:54:38 |
Message-ID: | CAM3SWZSGr7v7c=0M2Hh1nSaLD9dN83YvohzV0OBs7LbGF+mX8A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Apr 26, 2015 at 6:34 AM, Stephen Frost <sfrost(at)snowman(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Euler Taveira | 2015-04-26 18:03:42 | Re: parallel mode and parallel contexts |
Previous Message | Andres Freund | 2015-04-26 17:08:05 | Re: fix typos in comments |