Re: BEGIN inside transaction should be an error

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Mario Weilguni <mweilguni(at)sime(dot)com>, pgsql-hackers(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>, Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
Subject: Re: BEGIN inside transaction should be an error
Date: 2006-05-11 20:16:05
Message-ID: 1147378565.28245.58.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Wed, 2006-05-10 at 21:24 -0400, Tom Lane wrote:
> Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> > How do other database deal with this? Either they nest BEGIN/COMMIT or
> > they probably throw an error without aborting the transaction, which is
> > pretty much what we do. Is there a database that actually aborts a
> > whole transaction just for an extraneous begin?
>
> Probably not. The SQL99 spec does say (in describing START TRANSACTION,
> which is the standard spelling of BEGIN)
>
> 1) If a <start transaction statement> statement is executed when an
> SQL-transaction is currently active, then an exception condition
> is raised: invalid transaction state - active SQL-transaction.
>
> *However*, they are almost certainly expecting that that condition only
> causes the START command to be ignored; not that it should bounce the
> whole transaction. So I think the argument that this is required by
> the spec is a bit off base.

If you interpret the standard that way then the correct behaviour in the
face of *any* exception condition should be *not* abort the transaction.
In PostgreSQL, all exception conditions do abort the transaction, so why
not this one? Why would we special-case this?

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2006-05-11 20:46:58 Re: Compressing table images
Previous Message Brian Hurt 2006-05-11 20:09:01 Compressing table images

Browse pgsql-patches by date

  From Date Subject
Next Message Luke Lonergan 2006-05-11 21:42:32 Re: [PATCH] Improve EXPLAIN ANALYZE overhead by
Previous Message Jim C. Nasby 2006-05-11 20:07:11 Re: BEGIN inside transaction should be an error