| From: | Lincoln Yeoh <lylyeoh(at)mecomb(dot)com> | 
|---|---|
| To: | Mike Mascari <mascarm(at)mascari(dot)com> | 
| Cc: | davidb(at)vectormath(dot)com, pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Revisited: Transactions, insert unique. | 
| Date: | 2000-04-25 07:56:52 | 
| Message-ID: | 3.0.5.32.20000425155652.008dbb60@pop.mecomb.po.my | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
At 10:17 PM 24-04-2000 -0400, Mike Mascari wrote:
>Lincoln Yeoh wrote:
>PostgreSQL implements SELECT...FOR UPDATE to allow for the
>sequence you'be described:
>
>Session 1:
>
>BEGIN;
>SELECT webuser FROM webusers WHERE webuser = 'webuser1';
>
>Session 2:
>
>BEGIN;
>UPDATE webusers SET webuser = 'webuser2' WHERE webuser =
>'webuser1';*
The 6.5.3 running on my site does not block for the case I described which
has an INSERT after the select. 
begin;
select from mytable where field=value for update;
if rows=0 {
	insert into mytable (field,field2) values (value,value2);
} else {
	update mytable set field=value, field2=value2;
}
commit;
Tested on 6.5.3. 
Did a select for update in two concurrent transactions, they did not block,
and both inserts went through (if there was a unique, one of the
transactions would have had to be rolled back and redone from scratch).
If the behaviour is different for 7.0, I'm interested!
Cheerio,
Link.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fabrice Scemama | 2000-04-25 09:58:11 | Re: Is 7.0 ready? | 
| Previous Message | Stephan Richter | 2000-04-25 06:19:25 | PyGres DB Connection in Zope drops when many Users are added (UserDB) |