Bug #81227 [Opn]: PDO::inTransaction reports false when in transaction

From: Date: Tue, 06 Jul 2021 15:34:24 +0000
Subject: Bug #81227 [Opn]: PDO::inTransaction reports false when in transaction
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234832@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81227&edit=1 ID: 81227 User updated by: shariefjamiel at gmail dot com Reported by: shariefjamiel at gmail dot com Summary: PDO::inTransaction reports false when in transaction Status: Open Type: Bug Package: PDO SQLite Operating System: Ubuntu 20.04 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I am getting a race condition with sqlite when executing a script at the exact same second, hence why I am trying to use this exclusive transaction feature. Would it make more sense to add an option to beginTransaction method, to offer better backwards compatibility. Previous Comments: ------------------------------------------------------------------------ [2021-07-06 15:18:15] cmb@php.net PDO_SQLite does not implement an in_txn handler, and so the transaction status is only tracked according to PDO::beginTransaction() and friends. To be able to implement the in_txn handler, we would need to employ the sqlite3_txn_state() function, which is only available as of SQLite3 3.34.0 (2020-12-01), and still marked as draft in the docs[1]. [1] <https://sqlite.org/draft/c3ref/txn_state.html> ------------------------------------------------------------------------ [2021-07-06 14:33:54] shariefjamiel at gmail dot com Description: ------------ Using PHP 8.0.1 on Ubuntu 20.04 focal I am executing BEGIN EXCLUSIVE TRANSACTION due to a locking issue, but the problem is PDO::inTransaction returns false despite being in a transaction, which leads to errors later on. Test script: --------------- $db->exec("BEGIN EXCLUSIVE TRANSACTION"); $alwaysFalse = $db->inTransaction(); Expected result: ---------------- $db->exec("BEGIN EXCLUSIVE TRANSACTION"); $shouldBeTrue = $db->inTransaction(); Actual result: -------------- $db->exec("BEGIN EXCLUSIVE TRANSACTION"); $false = $db->inTransaction(); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81227&edit=1

« previous php.bugs (#234832) next »