Bug #62847 [Opn->Ver]: PDO not released (or disconnect) if last query was error.

From: Date: Fri, 01 Jul 2016 14:35:50 +0000
Subject: Bug #62847 [Opn->Ver]: PDO not released (or disconnect) if last query was error.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201964@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62847&edit=1 ID: 62847 Updated by: cmb@php.net Reported by: softwareelves at gmail dot com Summary: PDO not released (or disconnect) if last query was error. -Status: Open +Status: Verified Type: Bug Package: PDO Core Operating System: OSX 10.8 PHP Version: 5.3.16 Block user comment: N Private report: N New Comment: Apparently, this issue has been resolved as of PHP 7.0.0 (tested with 7.0.0 and 7.0.7 on Windows and current master on Linux). Previous Comments: ------------------------------------------------------------------------ [2016-07-01 09:56:20] cmb@php.net There is already request #62065, which suggests to add a disconnect() method. I don't mark this ticket as duplicate, though, because this issue might be fixable without adding a new method. ------------------------------------------------------------------------ [2016-07-01 09:13:09] cmb@php.net Related To: Bug #69730 ------------------------------------------------------------------------ [2016-04-06 21:44:42] doug at opendns dot com This is still reproducible in 5.6.19, and I can confirm that the attached test script still works (or, more accurately, doesn't work). Since PDO lacks an explicit disconnect method, this bug is kind of a pain. ------------------------------------------------------------------------ [2013-06-08 04:26:51] rgagnon24 at gmail dot com Similar but different stuff happens under PHP5.4.14 It seems the PDOStatement object gets a reference to the PDO it was executed on, but when the PDOStatement errors or causes a PDOException (depending on the PDO::ATTR_ERROR_MODE), then the reference to the PDO object is not released, and you end up with a live database connection, but no way to close or control it. ------------------------------------------------------------------------ [2012-08-17 17:14:21] softwareelves at gmail dot com Description: ------------ If PDO errors on it's LAST query it will refuse to disconnect from the database until the end of the script. Test script: --------------- <?php $get_new_pdo = function() { return new PDO( ... ); }; $pdo1 = $get_new_pdo(); $pdo2 = $get_new_pdo(); $base_line = count( $pdo1->query( "SHOW PROCESSLIST;" )->fetchAll() ); $pdo2->query( "SELECT column FROM non_existent_table;" ); //$pdo2->query( "SELECT 1;" ); //uncommenting this line causes $pdo2 to be released correctly $pdo2 = NULL; $after_unset = count( $pdo1->query( "SHOW PROCESSLIST;" )->fetchAll() ); var_dump( $base_line - $after_unset ); ?> Expected result: ---------------- int(1) Actual result: -------------- int(0) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62847&edit=1

« previous php.bugs (#201964) next »