Re: Strange result using transactions

Поиск
Список
Период
Сортировка
От Stuart Cooper
Тема Re: Strange result using transactions
Дата
Msg-id 7fc8628a0703262023u16970753o7d43d37a42d30b@mail.gmail.com
обсуждение исходный текст
Ответ на Strange result using transactions  ("Matthijs Melissen" <melissen@phil.uu.nl>)
Список pgsql-general
> I am executing the following queries (id has a unique key):

> 1) begin;
> 1) delete from forum where id = 20;
> 1) insert into forum (id, name) values (20, 'test');
> 2) delete from forum where id = 20;
> 1) commit;

If you do these side by side in interactive psql sessions, you'll see that the
process 2) delete from forum where id=20; waits and waits and doesn't start
until you commiut process 1). So from the point of view of Process 2,
it sees the committed forum table and it has no entries in the forum table with
id 20, hence DELETE 0 is its output.

So the effective sequence of events is:
1) begin;
1) delete from forum where id = 20;
1) insert into forum (id, name) values (20, 'test');
1) commit;
2) delete from forum where id = 20;

Hope this helps,
Stuart.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_dump without psql rights
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Strange result using transactions