Re: How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously? - Mailing list pgsql-general

From Alex Hunsaker
Subject Re: How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously?
Date
Msg-id 34d269d40907292130n2cffd20g25baf9f8b51f530c@mail.gmail.com
Whole thread Raw
In response to Re: How to prevent duplicate key error when two processes do DELETE/INSERT simultaneously?  (Brodie Thiesfield <brofield+pgsql@gmail.com>)
List pgsql-general
On Wed, Jul 29, 2009 at 19:53, Brodie
Thiesfield<brofield+pgsql@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 duplicate key, UPDATE
>

You can use plpgsql to emulate insert or replace (I think there are
some comments on emulating mysql specifically in the commented
versions of the docs somewhere... but thats up to you to find em) see
http://www.postgresql.org/docs/8.4/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
example 38-1

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Blog post about Amazon Elastic Block Storage
Next
From: Thomas Kellerer
Date:
Subject: pg_stat_activity undocumented?