Re: How can I know if a row is Locked? - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: How can I know if a row is Locked?
Date
Msg-id 20070413114854.GM24558@a-kretschmer.de
Whole thread Raw
In response to How can I know if a row is Locked?  (Carlos Santos <carloscompels@yahoo.com.br>)
List 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 by date:

Previous
From: Carlos Santos
Date:
Subject: How can I know if a row is Locked?
Next
From: Andrew Sullivan
Date:
Subject: Re: A long-running transaction