Re: [HACKERS] MERGE SQL Statement for PG11
Pavan Deolasee <pavan.deolasee@gmail.com>
From: Pavan Deolasee <pavan.deolasee@gmail.com>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Robert Haas <robertmhaas@gmail.com>,
Tomas Vondra <tomas.vondra@2ndquadrant.com>, Simon Riggs <simon@2ndquadrant.com>,
Alvaro Herrera <alvherre@alvh.no-ip.org>, Andrew Dunstan <andrew.dunstan@2ndquadrant.com>, Pavan Deolasee <pavan.deolasee@2ndquadrant.com>,
Stephen Frost <sfrost@snowman.net>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-03-05T11:02:42Z
Lists: pgsql-hackers
Attachments
- merge_v18a.patch (application/octet-stream) patch
On Fri, Mar 2, 2018 at 12:36 AM, Peter Geoghegan <pg@bowt.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
Commits
-
Add support for MERGE SQL command
- 7103ebb7aae8 15.0 landed
-
Add API of sorts for transition table handling in trigger.c
- 3a46a45f6f00 15.0 landed
-
Revert MERGE patch
- 08ea7a2291db 11.0 cited
-
Fix several bugs related to ON CONFLICT's EXCLUDED pseudo relation.
- ad2278379244 9.6.0 cited