BEGIN inside transaction should be an error - Mailing list pgsql-hackers

From Dennis Bjorklund
Subject BEGIN inside transaction should be an error
Date
Msg-id 446169D7.20203@zigo.dhs.org
Whole thread Raw
Responses Re: BEGIN inside transaction should be an error
Re: BEGIN inside transaction should be an error
List pgsql-hackers
Hi

Yesterday I helped a guy on irc with a locking problem, he thought
that locking in postgresql was broken. It turned out that he had a PHP
function that he called inside his transaction and the function did BEGIN
and COMMIT. Since BEGIN inside a transaction is just a warning what
happend was that the inner COMMIT ended the transaction and
released the locks. The rest of his commands ran with autocommit
and no locks and he got broken data into the database.

Could we make BEGIN fail when we already are in a transaction?

Looking it up in the sql99 standard I find this:

"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."

/Dennis


pgsql-hackers by date:

Previous
From: kris.shannon@gmail.com
Date:
Subject: Re: Constraint Exclusion + Joins?
Next
From: Tom Lane
Date:
Subject: Re: BEGIN inside transaction should be an error