Re: possible to lock a single row in table?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruno Boettcher <bboett(at)erm1(dot)u-strasbg(dot)fr>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: possible to lock a single row in table?
Date: 2001-06-20 15:54:02
Message-ID: Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-06-20 16:43:37 Re: possible to lock a single row in table?
Previous Message Josh Berkus 2001-06-20 14:54:59 Re: [SQL] log file