Re: UPDATE w/ subselect doing locking - Mailing list pgsql-general

From Brent Verner
Subject Re: UPDATE w/ subselect doing locking
Date
Msg-id 20011115151841.A3393@rcfile.org
Whole thread Raw
In response to Re: UPDATE w/ subselect doing locking  (David Ford <david@blue-labs.org>)
List 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

pgsql-general by date:

Previous
From: Fernando San Martín Woerner
Date:
Subject: Create Rule
Next
From: Peter Losher
Date:
Subject: Compiling v7.1.3 w/OpenSSL and Krb5 support...