BEGIN inside transaction should be an error

From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: BEGIN inside transaction should be an error
Date: 2006-05-10 04:19:35
Message-ID: 446169D7.20203@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-05-10 06:19:18 Re: BEGIN inside transaction should be an error
Previous Message kris.shannon 2006-05-10 04:00:12 Re: Constraint Exclusion + Joins?

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-05-10 06:19:18 Re: BEGIN inside transaction should be an error
Previous Message Martijn van Oosterhout 2006-05-09 21:38:54 Re: [PATCH] Improve EXPLAIN ANALYZE overhead by sampling