php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54478 The pdo_pgsql specific implementation of inTransaction doesn't work as expected
Submitted: 2011-04-06 14:59 UTC Modified: 2011-05-31 11:01 UTC
From: phofstetter at sensational dot ch Assigned: iliaa (profile)
Status: Closed Package: PDO related
PHP Version: 5.3.6 OS: OSX, Linux, likely all
Private report: No CVE-ID: None
 [2011-04-06 14:59 UTC] phofstetter at sensational dot ch
Description:
------------
PHP 5.3.3 supposedly brought PDO::inTransaction() with a special implementation 
for PostgreSQL wich uses libpq's PQtransactionStatus instead of internal 
bookkeeping.

According to the test attached with the revision where this was added 
(is_in_transaction.phpt, revision 300351), inTransaction() is supposed to return 
any of the PGSQL_TRANSACTION_* constants.

Unfortunately that's not the case and inTransaction(), even when used in 
conjunction with PostgreSQL only returns boolean and doesn't use the actual 
transaction status of the connection but just returns true or false depending on 
whether PDO::beginTransaction() has been called or not.

PHP's own test runner illustrates the problem, which is why I don't bother 
adding an additional test script - the included is_in_transaction.phpt is 
enough:

http://gcov.php.net/viewer.php?
version=PHP_5_3&func=tests&file=ext%2Fpdo_pgsql%2Ftests%2Fis_in_transaction.phpt

Expected result:
----------------
When running the phpt file, I expect the following output:

Test PDO::PGSQL_TRANSACTION_INTRANS
int(2)
Test PDO::PGSQL_TRANSACTION_IDLE
int(0)
Test PDO::PGSQL_TRANSACTION_INERROR
int(3)
Test PDO::PGSQL_TRANSACTION_IDLE
int(0)


Actual result:
--------------
When running the phpt file, I (and PHP's webbased test runner) is getting


Test PDO::PGSQL_TRANSACTION_INTRANS
int(1)
Test PDO::PGSQL_TRANSACTION_IDLE
int(0)
Test PDO::PGSQL_TRANSACTION_INERROR
int(1)
Test PDO::PGSQL_TRANSACTION_IDLE
int(0)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-06 15:15 UTC] phofstetter at sensational dot ch
A bit of investigation revealed that the feature was removed in 300464

http://svn.php.net/viewvc?view=revision&revision=300464

I guess the unit test should be removed too, as well as the note in the manual 
which states "Note that currently only the PostgreSQL driver implements this 
method."
 [2011-05-31 11:01 UTC] iliaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa
 [2011-05-31 11:01 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 01:03:40 2021 UTC