Re: Nested Transactions, Abort All

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Nested Transactions, Abort All
Date: 2004-07-08 19:37:27
Message-ID: 20040708193727.GH10089@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 08, 2004 at 10:40:36AM -0700, Josh Berkus wrote:

> This means that we CANNOT maintain compatibility with other databases without
> supporting SAVEPOINT syntax, which we are not yet ready to do. As a result,
> I would propose the following syntax:
>
> Begin main transaction: BEGIN { TRANSACTION | WORK }
> Begin inner transaction: BEGIN { TRANSACTION | WORK }
> Commit inner transaction: COMMIT { TRANSACTION | WORK }
> Commit all transactions: COMMIT ALL
> Rollback inner transaction: ROLLBACK { TRANSACTION }
> Rollback all transanctions: ROLLBACK ALL

We can _not_ do this. The reason is that COMMIT and ROLLBACK are
defined per spec to end the transaction. So they have to end the
transaction.

Keep in mind that a nested transaction _is not_ a transaction. You
cannot commit it; it doesn't behave atomically w.r.t. other concurrent
transactions. It is not a transaction in the SQL meaning of a
transaction.

So, when I say "it has to end the transaction" it cannot just end the
current nested transaction. It has to end the _real_ transaction.

My proposal would be:

1. Begin main transaction: BEGIN { TRANSACTION | WORK }
2. Commit main (all) transaction: COMMIT { TRANSACTION | WORK }
3. Rollback main (all) transaction: ROLLBACK { TRANSACTION }

4. Begin inner transaction: BEGIN NESTED { TRANSACTION | WORK }
5. Commit inner transaction: COMMIT NESTED { TRANSACTION | WORK }
6. Rollback inner transaction: ROLLBACK NESTED { TRANSACTION }

1, 2 and 3 are not negotiable. 4, 5 and 6 are.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Essentially, you're proposing Kevlar shoes as a solution for the problem
that you want to walk around carrying a loaded gun aimed at your foot.
(Tom Lane)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2004-07-08 19:37:37 Re: plperl status
Previous Message Andrew Dunstan 2004-07-08 19:28:12 plperl status