Re: Simulating a SELECT..FOR UPDATE to LOCK and SELECT statement

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Simulating a SELECT..FOR UPDATE to LOCK and SELECT statement
Дата
Msg-id 11292.1035466966@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Simulating a SELECT..FOR UPDATE to LOCK and SELECT statement  (Ludwig Lim <lud_nowhere_man@yahoo.com>)
Ответы Problem: Referential Integrity Constraints lost
Список pgsql-sql
Ludwig Lim <lud_nowhere_man@yahoo.com> writes:
>   Is there a way to emulate a SELECT..FOR UPDATE to
> series of LOCK/SELECT statement.

No.  LOCK can only acquire table-level locks; the point of SELECT FOR
UPDATE is to acquire row-level locks.

>    I am surprised because according to the docs
> (version 7.2), it says:
>     ROW SHARE MODE  
>     Note: Automatically acquired by SELECT ... FOR
> UPDATE. 

SELECT FOR UPDATE gets a table-level lock just to ensure that the table
doesn't disappear from under it while it's doing its scan.  The ROW
SHARE lock is pretty weak though, and doesn't block anything less
drastic than DROP/ALTER TABLE or VACUUM FULL.

The 7.3 development docs are perhaps clearer about this; try
http://developer.postgresql.org/docs/postgres/explicit-locking.html
        regards, tom lane


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

Предыдущее
От: Achilleus Mantzios
Дата:
Сообщение: Re: ORDER the result of a query by date
Следующее
От: "Charles H. Woloszynski"
Дата:
Сообщение: Help on creating a High Availability PostgreSQL solution?