pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Bruno Boettcher <bboett@erm1.u-strasbg.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: possible to lock a single row in table?
Date: Wed, 20 Jun 2001 17:54:02 +0200 (CEST)
Message-ID: <Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain> (raw)
In-Reply-To: <20010620164636.J13678@erm1.u-strasbg.fr>

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




view thread (3+ messages)  latest in thread

Message-ID: <Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain>
Permalink:  ../Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain/
Also on:    postgresql.org/message-id/Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: peter_e@gmx.net, bboett@erm1.u-strasbg.fr
  Subject: Re: possible to lock a single row in table?
  In-Reply-To: <Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain>
  References: <20010620164636.J13678@erm1.u-strasbg.fr> <Pine.LNX.4.30.0106201750500.725-100000@peter.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox