Re: Nested Transaction TODO list - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Nested Transaction TODO list
Date
Msg-id 20040705041938.GC3329@dcc.uchile.cl
Whole thread Raw
In response to Re: Nested Transaction TODO list  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: Nested Transaction TODO list  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-hackers
On Mon, Jul 05, 2004 at 03:38:13PM +1200, Oliver Jowett wrote:

> As I just mentioned in another thread, whatever the syntax for nested 
> transactions I'd like to see plain COMMIT/ABORT/ROLLBACK always affect 
> the top-level transaction.
> 
> Oracle appears to have:
> 
>   SAVEPOINT savepointname
>   ROLLBACK [WORK] [TO [SAVEPOINT] savepointname]

Right ... this is also what the standard defines.  A slight difference
from your description is that if one issues ROLLBACK TO savepointname
everything from the savepoint is rolled back, but the savepoint itself
is kept, so later I can roll back to it again.

> One generalization of this to nested transactions would be:
> 
>  SUBBEGIN [transactionname]
>  SUBCOMMIT [transactionname]
>  SUBABORT [transactionname]

The only departure from the SAVEPOINT syntax is that you are able to
"subcommit" a savepoint.  Not sure how useful that is ...


> Active transactions may have names. SUBBEGIN with a name associates the 
> name with the new transaction; if the name is already in use, it's also 
> removed from the old transaction. Alternatively we could only look at 
> the most-deeply-nested transaction with a given name when specifying 
> transactions by name.

Interesting idea ... it's also easier to implement.  Also maybe it can
be used to simplify life for PL handlers aborting a function.

> We could spell SUBBEGIN and friends differently -- is it better to add 
> more syntax to the existing transaction manipulation commands along the 
> lines of "BEGIN [NESTED] [TRANSACTION|WORK] [transactionname]", 
> "ROLLBACK [NESTED] [TRANSACTION|WORK] [transactionname]" etc?

Not sure.  I already implemented SUBBEGIN.  How does that work for
everyone?  I don't see much value in overloading BEGIN/ROLLBACK.

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El día que dejes de cambiar dejarás de vivir"



pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: Adding column comment to information_schema.columns
Next
From: Justin Clift
Date:
Subject: Re: Adding column comment to information_schema.columns