Re: update table with row locking

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: update table with row locking
Дата
Msg-id 20041229181924.GA10760@wolff.to
обсуждение исходный текст
Ответ на Re: update table with row locking  (Mark <sendmailtomark@yahoo.com>)
Ответы Re: update table with row locking  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Wed, Dec 29, 2004 at 07:02:51 -0800,
  Mark <sendmailtomark@yahoo.com> wrote:
> In general I need to lock whole  table so only one session can
> perform update. I'm looking for solution that will work in both C++
> and Java.

You probably want to use LOCK. You can read the documention for that command
to help decide which lock you should take.

>
> Will 'SELECT FOR UPDATE' lock whole table?

No. It will only lock records visible to the current transaction.
In particular this won't keep other transactions from doing inserts
into the table.

> As per 'LOCK' will lock released if connection get closed abnormally?

I believe the locks get released when the backend process terminates.
Depending on how the client dies, there may be a significant delay before
the backend process terminates.

> ( example: hard crash on the client side, network interruptions,
> etc.) Can LOCK be used in JDBC or it's SQL92 standard?

I don't know, but I would be surprised if you couldn't.

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: loading only few rows from huge table
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: update table with row locking