From: | "Stuart Cooper" <stuart(dot)cooper(at)gmail(dot)com> |
---|---|
To: | "Matthijs Melissen" <melissen(at)phil(dot)uu(dot)nl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Strange result using transactions |
Date: | 2007-03-27 03:23:26 |
Message-ID: | 7fc8628a0703262023u16970753o7d43d37a42d30b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-03-27 03:29:45 | Re: Strange result using transactions |
Previous Message | Tom Lane | 2007-03-27 03:21:04 | Re: pg_dump without psql rights |