Re: Buggy SELEC ... FROM UPDATE ?

Поиск
Список
Период
Сортировка
От Helge Bahmann
Тема Re: Buggy SELEC ... FROM UPDATE ?
Дата
Msg-id Pine.LNX.4.21.0104101635010.13043-100000@lothlorien.stunet2.tu-freiberg.de
обсуждение исходный текст
Ответ на Buggy SELEC ... FROM UPDATE ?  (Patrice Espié <patrice.espie@univ-lyon2.fr>)
Список 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


В списке pgsql-novice по дате отправления:

Предыдущее
От: Patrice Espié
Дата:
Сообщение: Buggy SELEC ... FROM UPDATE ?
Следующее
От: Don Miller
Дата:
Сообщение: No echo on psql command