Re: Rows with exclusive lock

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Rows with exclusive lock
Дата
Msg-id 20060723161050.GC32458@surnet.cl
обсуждение исходный текст
Ответ на Re: Rows with exclusive lock  (Martin Marques <martin@bugs.unl.edu.ar>)
Ответы Re: Rows with exclusive lock
Список pgsql-sql
Martin Marques escribió:
> On Sat, 22 Jul 2006, Alvaro Herrera wrote:
> 
> >Martin Marques escribió:
> >>Is it posible to get an exclusive (read/write) lock on certain rows? I
> >>don't want to block the whole table, only certain rows, but I want it to
> >>be a read/write lock.
> >
> >That's what SELECT FOR UPDATE does.
> 
> Hi Alvaro,
> 
> 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.

IOW, SELECT FOR UPDATE blocks other SELECTs FOR UPDATE and SELECTs FOR
SHARE, but it does not block plain SELECT.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


В списке pgsql-sql по дате отправления:

Предыдущее
От: Florian Weimer
Дата:
Сообщение: Re: Rows with exclusive lock
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Referential integrity (foreign keys) across multiple tables