"Christopher Kings-Lynne" <[EMAIL PROTECTED]> writes:
>> Uh, why exactly do you think this is race-free?

> How about:

> INSERT INTO table SELECT 1, 'foo' WHERE NOT EXISTS (SELECT TRUE FROM table
> WHERE pkcol=1 FOR UPDATE);

> It's a lot more straightforward and has a FOR UPDATE.  Can this still cause
> unique constraint failures?

Certainly.  FOR UPDATE locks an existing row; it cannot lock the
condition of non-existence of a row.

                        regards, tom lane


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to