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 |
Subject: | Re: Buggy SELEC ... FROM UPDATE ? |
Date: | 2001-04-10 14:39:01 |
Message-ID: | Pine.LNX.4.21.0104101635010.13043-100000@lothlorien.stunet2.tu-freiberg.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Patrice Espié | 2001-04-10 14:43:30 | Re: Buggy SELEC ... FROM UPDATE ? |
Previous Message | Patrice Espié | 2001-04-10 14:30:18 | Buggy SELEC ... FROM UPDATE ? |