Re: Rows with exclusive lock - Mailing list pgsql-sql

From Andrew Hammond
Subject Re: Rows with exclusive lock
Date
Msg-id 1153941931.290674.125300@b28g2000cwb.googlegroups.com
Whole thread Raw
In response to Re: Rows with exclusive lock  (Martin Marques <martin@bugs.unl.edu.ar>)
List pgsql-sql
Martin Marques wrote:
> On Sun, 23 Jul 2006, Alvaro Herrera wrote:
>
> > Martin Marques escribió:
> >>
> >> After the SELECT FOR UPDATE other transactions can still see the locked
> >> rows. I want a read/write lock, so no one can access does rows.
> >
> > SELECT FOR UPDATE acquires an exclusive lock, but other transactions
> > must try to acquire a lock on the rows as well, or they won't be locked.
> > You can try using SELECT FOR SHARE (new as of 8.1) if you want some
> > transactions to hold shared (read) locks.
>
> Sorry for not getting it clear the first time.
>
> What I want is something like "LOCK table IN ACCESS EXCLUSIVE MODE", but
> at row level.

Well... you could change your other selects to use FOR UPDATE as well,
even if they're not going to be updating (but this block concurrent
reads). You're probably better to take Alvaro's suggestion above and
use SELECT FOR SHARE.

Drew



pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: SQL generator
Next
From: "Andrew Hammond"
Date:
Subject: Re: Help with privilages please