Re: Nested xacts: looking for testers and review

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Nested xacts: looking for testers and review
Date: 2004-06-09 19:09:03
Message-ID: 20040609190903.GA10510@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, May 30, 2004 at 04:07:27AM -0700, Stephan Szabo wrote:
> On Sat, 29 May 2004, Alvaro Herrera wrote:

> > Ah, this seems to work. I'll implement it and I'll let you know how it
> > goes.
>
> Ugh... There's one further wrinkle I hadn't thought about, imagine the
> following:

Ok Stephan, thank you very much for your help. I implemented this and
it seems to work, at least on my (limited?) test scenario. If you have
some spare time I'd like you to test it and see if you can break it (I
posted it to -patches yesterday).

Or please see my test case below. Is it missing something? Note that
if I take out any of the four inserts just before the end of the
transaction, the whole thing is rejected.

DROP TABLE foo CASCADE;
DROP TABLE bar CASCADE;
CREATE TABLE foo (A INT UNIQUE);
CREATE TABLE bar (A INT REFERENCES foo(A) DEFERRABLE);

DELETE FROM bar;
DELETE FROM foo;
INSERT INTO foo VALUES (1);
INSERT INTO foo VALUES (2);
BEGIN;
SET CONSTRAINTS ALL DEFERRED;
INSERT INTO bar VALUES (1);
BEGIN;
INSERT INTO bar VALUES (3);
COMMIT;
BEGIN;
BEGIN;
INSERT INTO bar VALUES (4);
COMMIT;
INSERT INTO foo VALUES (3);
SET CONSTRAINTS ALL IMMEDIATE;
ROLLBACK;
SET CONSTRAINTS ALL DEFERRED;
BEGIN;
INSERT INTO bar VALUES (5);
COMMIT;
BEGIN;
BEGIN;
INSERT INTO bar VALUES (6);
ROLLBACK;
COMMIT;
BEGIN;
INSERT INTO bar VALUES (7);
COMMIT;
BEGIN;
BEGIN;
INSERT INTO bar VALUES (9);
COMMIT;
COMMIT;
INSERT INTO foo VALUES(3);
INSERT INTO foo VALUES(5);
INSERT INTO foo VALUES(7);
INSERT INTO foo VALUES(9);
COMMIT;

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Acepta los honores y aplausos y perderás tu libertad"

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-06-09 19:27:10 Re: Nested xacts: looking for testers and review
Previous Message Tom Lane 2004-06-09 18:43:54 Re: Assignment to array elements