Re: UPDATE w/ subselect doing locking

From: Brent Verner <brent(at)rcfile(dot)org>
To: David Ford <david(at)blue-labs(dot)org>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: UPDATE w/ subselect doing locking
Date: 2001-11-15 20:18:41
Message-ID: 20011115151841.A3393@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15 Nov 2001 at 12:12 (-0500), David Ford wrote:
| Yes, I know that works. I want to figure out how to use SELECT ... FOR
| UPDATE with UPDATE because I will have a need to lock these certain rows
| and do a bit more than just 'count'.

AFAIK, you need to do the following the use the SELECT ... FOR UPDATE

BEGIN;
SELECT ... FOR UPDATE;
UPDATE ... SET ...;
COMMIT;

Any other session attempting an update on the selected for update rows
will block on the locked rows until the end of that xact.

hth.
brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing." -- Duane Allman

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Losher 2001-11-15 20:28:01 Compiling v7.1.3 w/OpenSSL and Krb5 support...
Previous Message Andrew G. Hammond 2001-11-15 20:18:03 Re: pgsql and large tables