Re: possible to lock a single row in table? - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: possible to lock a single row in table?
Date
Msg-id Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain
Whole thread Raw
In response to possible to lock a single row in table?  (bboett@erm1.u-strasbg.fr (Bruno Boettcher))
List pgsql-sql
Bruno Boettcher writes:

> i have a lots of threads that work on a table, making insertions,
> updates removes.....
>
> now i certain cases its important to keep data integrity, so i looked
> into locks....

Only in certain cases??? ;-)

> all i found was a lock function that locks the entire table....

There are also row level locks, which are automatically acquired when
needed.  The best way to lock specific rows is the SELECT ... FOR UPDATE
statement.  Playing with the LOCK command is generally not necessary.

> and what happens to other insert queries whilst the lock is operational?
> Are they postponed and the valling thread waits, or does the call return
> with an error?

That depends on the transaction isolation level (which you can set).  See
the chapter on concurrency control in the User's Guide for more
information.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



pgsql-sql by date:

Previous
From: David BOURIAUD
Date:
Subject: Help on a sql querry.
Next
From: hughmandeville@hotmail.com (Hugh Mandeville)
Date:
Subject: Re: binary data