Re: How can I know if a row is Locked?

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: How can I know if a row is Locked?
Дата
Msg-id 20070413114854.GM24558@a-kretschmer.de
обсуждение исходный текст
Ответ на How can I know if a row is Locked?  (Carlos Santos <carloscompels@yahoo.com.br>)
Список pgsql-sql
am  Fri, dem 13.04.2007, um  4:27:34 -0700 mailte Carlos Santos folgendes:
> How can I know if a row is locked by another transaction.
> I have in a transaction like that:
> 
> BEGIN;
> SELECT * FROM compels.teste WHERE id = '1' FOR UPDATE;
> 
> PS1: where id is the primary key.
> PS2: The COMMIT command is done after a long time.
> 
> In this case the row with the primary-key equals to '1' will be locked to other
> transactions until the COMMIT command be executed.
> So, how can I detect if this row is locked?

You can call the insert with 'for update nowait' and catch the error, if
an error occurs.

Maybe there are better solutions...


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


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

Предыдущее
От: Carlos Santos
Дата:
Сообщение: How can I know if a row is Locked?
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: A long-running transaction