Re: Row Locking - Mailing list pgsql-general

From Tom Lane
Subject Re: Row Locking
Date
Msg-id 22303.1021904646@sss.pgh.pa.us
Whole thread Raw
In response to Row Locking  (Alexander Klayman <aklayman@mindspring.com>)
Responses Re: Row Locking
Re: Row Locking
List 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 by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: Further thoughts on Referential Integrity
Next
From: Tom Lane
Date:
Subject: Re: PostgreSQL 7.1 forces sequence scan when there is no reason