From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> |
Cc: | "Hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Solution to UPDATE...INSERT problem |
Date: | 2003-03-27 07:13:28 |
Message-ID: | 9715.1048749208@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
"Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Lincoln Yeoh | 2003-03-27 09:19:18 | Re: Solution to UPDATE...INSERT problem |
Previous Message | Christopher Kings-Lynne | 2003-03-27 06:55:53 | Re: Solution to UPDATE...INSERT problem |
From | Date | Subject | |
---|---|---|---|
Next Message | Hiroshi Inoue | 2003-03-27 09:06:39 | Re: updateable cursors & visibility |
Previous Message | Christopher Kings-Lynne | 2003-03-27 06:55:53 | Re: Solution to UPDATE...INSERT problem |