> Uh, why exactly do you think this is race-free? > > It looks fancy, but AFAICS the SELECT will return info that is correct > as of its starting timestamp; which is not enough to guarantee that the > INSERT won't conflict with another transaction doing the same thing > concurrently.
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? Chris ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])