Re: Buggy SELEC ... FROM UPDATE ?

From: Patrice Espié <patrice(dot)espie(at)free(dot)fr>
To: "Helge Bahmann" <bahmann(at)math(dot)tu-freiberg(dot)de>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Buggy SELEC ... FROM UPDATE ?
Date: 2001-04-10 14:43:30
Message-ID: 008901c0c1cc$9c99ace0$0400a8c0@univlyon2.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


----- Original Message -----
From: "Helge Bahmann" <bahmann(at)math(dot)tu-freiberg(dot)de>
To: "Patrice Espié" <patrice(dot)espie(at)univ-lyon2(dot)fr>
Cc: <pgsql-novice(at)postgresql(dot)org>
Sent: Tuesday, April 10, 2001 4:39 PM
Subject: Re: [NOVICE] Buggy SELEC ... FROM UPDATE ?

> All locks are released when you commit your transaction.
>
> > boolean Got = false
> > while Got == false
> > Start transaction
> > SELECT * FROM syslock WHERE id=%d AND used='f' FOR UPDATE
> the row is locked here ...
> > if SELECT returns a row
> > then
> > UPDATE syslock SET used='t' WHERE id=%d
> > Commit transaction
> ... and released again here; probably not what you want
Sure, I want to release it : the other users MUST be free to go away instead
of being locked if they try to lock anything already locked
> > Got = true
> > else
> > Rollback transaction
> > continue // yes, active wait ... I'm testing !
> > end if
> > end while
> > Trace "I get the syslock number %d !!"
> > Do something with the syslock %d which is now reserved
> > UPDATE syslock SET used='f' WHERE id=%d
> should move your "commit transaction" here
>
> have fun
> helge
Another idea, please !!
Thank's

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Don Miller 2001-04-10 14:52:33 No echo on psql command
Previous Message Helge Bahmann 2001-04-10 14:39:01 Re: Buggy SELEC ... FROM UPDATE ?