Re: Nested Transaction TODO list

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Nested Transaction TODO list
Date: 2004-07-05 04:19:38
Message-ID: 20040705041938.GC3329@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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"

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Clift 2004-07-05 04:20:27 Re: Adding column comment to information_schema.columns
Previous Message Christopher Kings-Lynne 2004-07-05 04:13:38 Re: Adding column comment to information_schema.columns