SELECT ... FOR UPDATE

From: "Marcos Minshew" <mkm(at)outerscape(dot)net>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: SELECT ... FOR UPDATE
Date: 2001-03-28 22:53:30
Message-ID: NEBBIGINEKHHJJCNOBBJOEKFCGAA.mkm@outerscape.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I am interested in using the SELECT ... FOR UPDATE feature but it doesn't
work quite the way I had hoped. If there is a better/different way of doing
this please enlighten me.

If I issue:

BEGIN;
SELECT * FROM atable WHERE atable.key = 10 FOR UPDDATE;

in one session and then issue the same commands from a 2nd session, the 2nd
session simply waits until the 1st session issues COMMIT or ROLLBACK. While
the 2nd session is waiting I am, apparently locked out. What I would like
is for the 2nd session to determine if the lock can be obtained and if not,
offer the user a choice of waiting or escaping from the SELECT. Is this
possible?

Using 7.0.3

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Olbersen 2001-03-28 23:38:38 Self-Referencing
Previous Message Jim Ballard 2001-03-28 22:27:09 Re: RE: counting distinct rows on more than one column