Re: PostgreSQL transaction locking problem

Поиск
Список
Период
Сортировка
От Mike Mascari
Тема Re: PostgreSQL transaction locking problem
Дата
Msg-id 3C5C6E49.480F14F@mascari.com
обсуждение исходный текст
Ответ на Re: PostgreSQL transaction locking problem  ("Jeff Martin" <jeff@dgjc.org>)
Ответы Running postgresql problem??
Список pgsql-general
Jeff Martin wrote:
>
> first the case of my example is just that, an example.  i want to learn to
> use transactions and locking so that i can do the following....
>
> 1. run multiple processes in different transactions,
> 2. executing the same pg/sql functions which,
> 3. need to read data at the beginning of the function that is committed,
> 4. perform calculations and write a result.
> 5. thus competing processes will need to wait for each to commit the result
> in turn.

I kind of missed the beginning of this thread, so pardon me if I'm way
off base. But the behavior you describe just requires the use of
SELECT...FOR UPDATE. The second transaction will block awaiting the
COMMIT/ABORT of the first.

Session #1:

BEGIN;
SELECT balance FROM checking FOR UPDATE;

Session #2:

BEGIN;
SELECT balance FROM checking FOR UPDATE;

 ^== Blocks until Session #1 COMMITS/ABORTS


Hope that helps,

Mike Mascari
mascarm@mascari.com

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PostgreSQL transaction locking problem
Следующее
От: David Madore
Дата:
Сообщение: HASH index method not correctly handling NULL text values?