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>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: [HACKERS] Solution to UPDATE...INSERT problem |
Date: | 2003-03-27 06:41:29 |
Message-ID: | 9529.1048747289@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:
> INSERT INTO table SELECT 1, 'foo' EXCEPT SELECT 1, 'foo' FROM table WHERE
> pkcol=1;
> See? So now that INSERT statement will insert the row if it doesn't exist,
> or insert zero rows if it does. You are then guaranteed that your
> transaction will not fail and rollback, so you can repeat your update, or do
> the insert first and then the update, etc.
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.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Kings-Lynne | 2003-03-27 06:55:53 | Re: Solution to UPDATE...INSERT problem |
Previous Message | Lakshmi S. | 2003-03-27 06:09:58 | create type problem! |
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Kings-Lynne | 2003-03-27 06:55:53 | Re: Solution to UPDATE...INSERT problem |
Previous Message | Thomas T. Thai | 2003-03-27 05:28:01 | Re: BUG: Vacuum Analyze - datumGetSize: Invalid typLen 0 |