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