Re: Nested Transactions, Abort All

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: josh(at)agliodbs(dot)com, Oliver Jowett <oliver(at)opencloud(dot)com>, Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, Zeugswetter Andreas SB SD <ZeugswetterA(at)spardat(dot)at>, Andreas Pflug <pgadmin(at)pse-consulting(dot)de>, Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Nested Transactions, Abort All
Date: 2004-07-11 04:22:58
Message-ID: 20040711042258.GA14600@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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"
release foo; -- "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)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-07-11 05:05:47 Re: plperl (7.5)
Previous Message elein 2004-07-11 04:18:28 plperl (7.5)