[GENERAL] How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously?

2009-07-29 Thread Brodie Thiesfield
Hi, I've got a problem with a PG client that I'm not sure how to fix. Essentially, I have two processes connecting to a single PG database and simultaneously issuing the following statements: BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; DELETE FROM licence_properties WHERE key = xxx;

Re: [GENERAL] How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously?

2009-07-29 Thread Tom Lane
Brodie Thiesfield brofield+pg...@gmail.com writes: Essentially, I have two processes connecting to a single PG database and simultaneously issuing the following statements: BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; DELETE FROM licence_properties WHERE key = xxx; INSERT INTO

Re: [GENERAL] How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously?

2009-07-29 Thread Brodie Thiesfield
On Thu, Jul 30, 2009 at 12:23 AM, Tom Lanet...@sss.pgh.pa.us wrote: Brodie Thiesfield brofield+pg...@gmail.com writes: Essentially, I have two processes connecting to a single PG database and simultaneously issuing the following statements: BEGIN; SET TRANSACTION ISOLATION LEVEL

Re: [GENERAL] How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously?

2009-07-29 Thread Alex Hunsaker
On Wed, Jul 29, 2009 at 19:53, Brodie Thiesfieldbrofield+pg...@gmail.com wrote: On further investigation, since the logic requires the delete to be made first to get rid of other possible rows, so I'll go with: DELETE (if supported)  INSERT OR REPLACE (otherwise)             INSERT, if