Re: Nested Transactions, Abort All - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Nested Transactions, Abort All
Date
Msg-id 20040711042258.GA14600@dcc.uchile.cl
Whole thread Raw
In response to Re: Nested Transactions, Abort All  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Nested Transactions, Abort All  (Josh Berkus <josh@agliodbs.com>)
Re: Nested Transactions, Abort All  (Jan Wieck <JanWieck@Yahoo.com>)
List pgsql-hackers
On Sat, Jul 10, 2004 at 08:25:16PM -0400, Bruce Momjian wrote:

> Do we want to allow BEGIN NESTED to start a main transaction?

I have a better question: do we allow SAVEPOINT (i.e. to establish a
savepoint, i.e. to open a nested transaction) within an aborted
transaction block?

This is allowed in nested transactions, so:

begin; select 0/0;        -- aborts begin;   select 1;        -- the usual "commands will be ignored till the end"
commit;
commit;                -- it really rolls back

But in savepoints it's not clear that we want to allow to establish a
savepoint, so do you prefer

begin; select 0/0; savepoint foo;    -- "commands will be ignored" select 1;            -- "commands will be ignored"
releasefoo;        -- "commands will be ignored"
 
commit;                -- it really rolls back


Or

begin; select 0/0; savepoint foo;    -- executes it select 1;            -- "commands will be ignored" release foo;
  -- executes it
 
commit;                -- it really rolls back


There is not a lot of difference.  This was allowed in nested
transactions because we wanted the nesting be to OK when using it in a
possibly aborted transaction block, so the user would not commit a
transaction that could not have been created.  In savepoints it's a
nonissue because the command to end the outer xact is different.


My opinion is that we should disallow both SAVEPOINT and RELEASE when in
an aborted transaction block.  Only ROLLBACK TO, ROLLBACK and COMMIT
would be allowed.  In this scenario, ROLLBACK TO would always return to
a non-aborted transaction state, or the target savepoint would not
exist and the state would remain the same.

There are several places where the code could be made simpler with this.
Opinions please?

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Siempre hay que alimentar a los dioses, aunque la tierra esté seca" (Orual)



pgsql-hackers by date:

Previous
From: elein
Date:
Subject: plperl (7.5)
Next
From: Alvaro Herrera
Date:
Subject: Re: plperl (7.5)