pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: How can I know if a row is Locked?
Date: Fri, 13 Apr 2007 13:48:54 +0200
Message-ID: <20070413114854.GM24558@a-kretschmer.de> (raw)
In-Reply-To: <651844.97452.qm@web57110.mail.re3.yahoo.com>
References: <651844.97452.qm@web57110.mail.re3.yahoo.com>

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



view thread (3+ messages)

Message-ID: <20070413114854.GM24558@a-kretschmer.de>
Permalink:  ../20070413114854.GM24558@a-kretschmer.de/
Also on:    postgresql.org/message-id/20070413114854.GM24558@a-kretschmer.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andreas.kretschmer@schollglas.com
  Subject: Re: How can I know if a row is Locked?
  In-Reply-To: <20070413114854.GM24558@a-kretschmer.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox