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

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Date: 2014-10-24 17:30:46
Message-ID: CA+TgmoYuH=sAa9DrdygQ5+RbVZ4u8hGpue-9E-hwT-CE7kgWhA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 24, 2014 at 1:18 PM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> On 10/24/2014 10:04 AM, Robert Haas wrote:
>> As far as syntax goes, I thought the INSERT .. ON CONFLICT UPDATE
>> syntax proposed upthread was the best of any mentioned thus far. The
>> MERGE-based syntaxes proposed upthread were crazily verbose for no
>> discernable benefit.
>
> For those of us who haven't followed every post in this thread, is there
> somewhere I can see the proposed syntax?

There are a couple of different proposals but this should give you a
feeling for where we're at:

http://www.postgresql.org/message-id/CA+TgmoZN=2AJKi1n4Jz5BkmYi8r_CPUDW+DtoppmTeLVmsOoqw@mail.gmail.com

The part I like is the idea of making UPSERT look like an INSERT
statement with an additional clause that says how a unique violation
should be handled. The part nobody except Peter likes is using
functional notation like CONFLICTING() or EXCLUDED() to pull in values
from the tuple causing the unique violation. And there are some other
areas of disagreement about particular keywords and so on. But I
personally like that general style much more than the alternatives
derived from MERGE.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-10-24 17:32:31 Re: Question about RI checks
Previous Message Florian Pflug 2014-10-24 17:28:24 Re: Question about RI checks