Re: [HACKERS] MERGE SQL Statement for PG11

From: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Pavan Deolasee <pavan(dot)deolasee(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] MERGE SQL Statement for PG11
Date: 2018-03-05 11:02:42
Message-ID: CABOikdPFCcgp7=zoN4M=y0TefW4Q9dPAU+Oy5jN5A+hWYdnvNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 2, 2018 at 12:36 AM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:

>
> > Our regular UPDATE .. FROM does not do that
> > either. Given that, it seems better to just throw an error (even when no
> NOT
> > MATCHED action exists) and explain to the users that MERGE will work as
> long
> > as concurrent updates don't modify the columns used in the join
> condition.
> > Concurrent deletes should be fine and we may actually even invoke WHEN
> NOT
> > MATCHED action in that case.
>
> Again, I have to ask: is such an UPDATE actually meaningfully
> different from a concurrent DELETE + INSERT? If so, why is a special
> error better than a dup violation, or maybe even having the INSERT
> (and whole MERGE statement) succeed?
>
>
Ok, I agree. I have updated the patch to remove the serialization error. If
MATCHED changes to NOT MATCHED because of concurrent update/delete, we now
simply retry from the top and execute the first NOT MATCHED action, if WHEN
AND qual passes on the updated version. Of course, if the MERGE does not
contain any NOT MATCHED action then we simply ignore the target row and
move to the next row. Since a NOT MATCHED case can never turn into a
MATCHED case, there is no risk of a live lock.

I've updated the documentation and the test cases to reflect this change.

Thanks,
Pavan

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

Attachment Content-Type Size
merge_v18a.patch application/octet-stream 283.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2018-03-05 11:25:36 Re: [HACKERS] Support for Secure Transport SSL library on macOS as OpenSSL alternative
Previous Message Daniel Gustafsson 2018-03-05 10:56:21 Re: Better Upgrades