From: | "Peter Darley" <pdarley(at)kinesis-cem(dot)com> |
---|---|
To: | "Mike Mascari" <mascarm(at)mascari(dot)com> |
Cc: | "Lincoln Yeoh" <lyeoh(at)pop(dot)jaring(dot)my>, "Mark Harrison" <mh(at)pixar(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: most idiomatic way to "update or insert"? |
Date: | 2004-08-05 13:56:17 |
Message-ID: | PDEOIIFFBIAABMGNJAGPCEGODKAA.pdarley@kinesis-cem.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Mike,
Ahha! I didn't understand what the objection was. I guess I am getting
lucky. :)
It seems to me that this is true with any concurrent inserts, isn't it?
One will succeed and one will fail.
Thanks,
Peter Darley
-----Original Message-----
From: Mike Mascari [mailto:mascarm(at)mascari(dot)com]
Sent: Thursday, August 05, 2004 6:51 AM
To: Peter Darley
Cc: Lincoln Yeoh; Mark Harrison; pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] most idiomatic way to "update or insert"?
Peter Darley wrote:
> Lincoln, It works for me... I think what you said is wrong
> because it updates first (if there is a row to update), then
> inserts. If there is a row to update the insert won't insert
> anything. If there is no row to update the insert inserts a row.
> Either way, the insert is the last thing in the transaction.
> Plus, as shown in the code to follow, I have almost this exact
> thing in my application and I know that it does work for me. :)
You're getting lucky. I suggested the same thing four years ago. The
race condition is still there:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=2344.978158285%40sss
.pgh.pa.us
HTH,
Mike Mascari
From | Date | Subject | |
---|---|---|---|
Next Message | marcelo Cortez | 2004-08-05 14:00:56 | Non-superuser connection limit exceeded |
Previous Message | Csaba Nagy | 2004-08-05 13:52:33 | Re: most idiomatic way to "update or insert"? |