Re: UPSERT

Bruno Wolff III <bruno@wolff.to>

From: Bruno Wolff III <bruno@wolff.to>
To: Hannu Krosing <hannu@skype.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andrew Dunstan <andrew@dunslane.net>, Jonathan Scher <js@oxado.com>, pgsql-hackers@postgresql.org
Date: 2007-03-04T13:46:58Z
Lists: pgsql-hackers
On Sun, Mar 04, 2007 at 14:55:47 +0200,
  Hannu Krosing <hannu@skype.net> wrote:
> 
> UPDATE
> IF NOT FOUND THEN 
>   INSERT
>   IF DUPLICATE KEY THEN
>     UPDATE
>   END IF
> END IF

I believe it is possible for the above to fail. For example another
transaction could create a matching record between the update and insert
and then another transaction could delete it between the insert and the
second update.