Re: Row Locking

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Row Locking
Дата
Msg-id 22303.1021904646@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Row Locking  (Alexander Klayman <aklayman@mindspring.com>)
Ответы Re: Row Locking
Re: Row Locking
Список pgsql-general
Alexander Klayman <aklayman@mindspring.com> writes:
> LOCK TABLE A IN ROW EXCLUSIVE MODE;
> SELECT c FROM A WHERE id=1;   # The row with d=1 is locked

You seem to have a fundamental misconception about what sort of locking
Postgres does.

LOCK TABLE gets table-level locks of various kinds.  The names for the
lock types are fairly bizarre and unhelpful IMHO, but they are all
*table* level, without exception; and there is no change in the behavior
of other statements.

The only sorts of row-level locks we use are those acquired by
updating/deleting an existing row, or equivalently by SELECT FOR UPDATE
(which doesn't change the row, but marks it as if it did).  These
locks do not prevent another transaction from reading the row with
SELECT --- only from updating, deleting, or selecting it FOR UPDATE.

All locks are held till transaction commit.

            regards, tom lane

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

Предыдущее
От: "Joel Burton"
Дата:
Сообщение: Re: Further thoughts on Referential Integrity
Следующее
От: Tom Lane
Дата:
Сообщение: Re: PostgreSQL 7.1 forces sequence scan when there is no reason