PHP PDO bug with begintransaction

140 views
Skip to first unread message

Jan Derk Stegeman

unread,
Jun 9, 2022, 3:29:07 PM6/9/22
to firebird-support
I filed a bug report with PHP PDO that begintransaction raises an "transaction already exists exception" if a query has been performed before calling begintransaction. The PHP documentation states that begintransaction should turn off autocommit, which is not what is happening.

Looks like in autocommit mode a transaction is always committed and retained for any query. My workaround has been to disable autocommit before the begintransaction part and reenable after commit or rollback.

My question: Is this a bug in the PDO driver? This goes over my head.

Any expert that could chime in on the PHP bug report so things get straightened out is very welcome. Looks to the non-expert, me, like this is a bug. But maybe it just should get documented better.

Mark Rotteveel

unread,
Jun 10, 2022, 2:47:57 AM6/10/22
to firebird...@googlegroups.com
On 09-06-2022 15:29, Jan Derk Stegeman wrote:
> I filed a bug report with PHP PDO
> <https://github.com/php/php-src/issues/8735> that begintransaction
> raises an "transaction already exists exception" if a query has been
> performed before calling begintransaction. The PHP documentation
> <https://www.php.net/manual/en/pdo.begintransaction.php> states that
> begintransaction should turn off autocommit, which is not what is happening.
>
> Looks like in autocommit mode a transaction is always committed and
> retained for any query. My workaround has been to disable autocommit
> before the begintransaction part and reenable after commit or rollback.
>
> My question: Is this a bug in the PDO driver? This goes over my head.
>
> Any expert that could chime in on the PHP bug report so things get
> straightened out is very welcome. Looks to the non-expert, me, like this
> is a bug. But maybe it just should get documented better.

This is a question that might be more suitable to ask on the
firebird-php Google Group (https://groups.google.com/g/firebird-php).

However, yes it sounds like a bug, something they confirmed in your bug
report. The "Firebird driver" mentioned by cmb69 is pdo-firebird
(https://github.com/php/php-src/tree/master/ext/pdo_firebird).

The problem is that Firebird itself doesn't have a suitable auto-commit
mode that automatically starts and completes transactions when
necessary, so a driver must handle starting and completingtransactions
for auto-commit itself, and the way pdo-firebird does this, doesn't
handle the requirements documented for PDO's beginTransaction.

Mark
--
Mark Rotteveel

Jan Derk Stegeman

unread,
Jun 10, 2022, 8:36:23 AM6/10/22
to firebird-support
Thanks for your response. I hope you don't mind that I added your response to the PHP bug report. Hopefully there will be a solution to make things clearer for other Firebird PDO users. 
Reply all
Reply to author
Forward
0 new messages