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

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Simon Riggs <simon(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-09-29 22:02:23
Message-ID: 20140929220223.GI2084@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-09-29 14:57:45 -0700, Kevin Grittner wrote:
> Peter Geoghegan <pg(at)heroku(dot)com> wrote:
>
> > I think the fact that no MERGE implementation does what you want
> > should be convincing. It is *horrifically* complicated to make
> > what you want work, if indeed it is technically feasible at all.
> > Isn't this already complicated enough?
>
> What about the MERGE syntax I posted makes it hard to implement the
> statement validation and execution code you already have? (I'm
> asking about for the UPSERT case only, not an implementation of all
> aspects of the standard syntax.)

> To recap, in summary that would be:
>
> MERGE INTO tablename [ alias ]
> USING ( relation ) [ alias ]
> ON ( boolean-expression )
> WHEN MATCHED THEN
> UPDATE SET target-column = expression
> [ , target-column = expression ] ...
> WHEN NOT MATCHED THEN
> INSERT ( target-columns ) VALUES ( expressions )
>
> The initial implementation could restrict to these exact clauses
> and require that the boolean-expression used equality-quals on all
> columns of a unique index on only NOT NULL columns.

That'll make it really hard to actually implement real MERGE.

Because suddenly there's no way for the user to know whether he's
written a ON condition that can implement UPSERT like properties
(i.e. the *precise* column list of an index) or not.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2014-09-29 22:04:02 Valgrind warnings in master branch ("Invalid read of size 8") originating within CreatePolicy()
Previous Message Kevin Grittner 2014-09-29 21:57:45 Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}