php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36449 Procedure call + PDO::ATTR_PERSISTENT => true
Submitted: 2006-02-18 21:55 UTC Modified: 2006-04-30 13:34 UTC
From: brice dot joly at free dot fr Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.0-dev OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: brice dot joly at free dot fr
New email:
PHP Version: OS:

 

 [2006-02-18 21:55 UTC] brice dot joly at free dot fr
Description:
------------
When calling a procedure from PDO with PDO::ATTR_PERSISTENT = true, I have a very strange behaviour when refreshing the page: on odd tries it works as expected, on even ones PDO makes the call, then loses connection while retrieving the result. Direct and prepared call both produce the same behaviour. Note that the call is actually ran by MySQL in both cases (appears in the query log).

When switching PDO::ATTR_PERSISTENT to false all works as expected.

Running the test with PHP CLI works fine. I run PHP (tested with snapshot of 17 Feb 2006, 5.1.3-dev, had the same problem with 5.1.2) as a module, Apache 2.0.52, MySQL 5.0.18.

Reproduce code:
---------------
// MySQL Procedure
CREATE PROCEDURE test.simpleTest()
BEGIN
  SELECT 'Procedure output';
END;

// PDO call
<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', 'user', 'password', array(PDO::ATTR_PERSISTENT => true);

foreach ($dbh->query("CALL simpleTest()") as $row) {
    print_r($row);
}
$arr = $dbh->errorInfo();
print_r($arr);

/* Same problem with
$stmt = $dbh->prepare("CALL simpleTest()");
$stmt->execute();
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
    print_r($row);
}
$arr = $stmt->errorInfo();
print_r($arr);
*/
?>

Expected result:
----------------
Array
(
    [Procedure output] => Procedure output
    [0] => Procedure output
)
Array
(
    [0] => 00000
)

on odd and even tries/refresh

Actual result:
--------------
On odd tries (1st, 3rd, etc.):

Array
(
    [Procedure output] => Procedure output
    [0] => Procedure output
)
Array
(
    [0] => 00000
)

on even tries (refresh)
Array
(
    [0] => HY000
    [1] => 2013
    [2] => Lost connection to MySQL server during query
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-09 07:54 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

The next snapshot dated after this message likely fixes this.
 [2006-04-17 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-04-27 10:38 UTC] brice dot joly at free dot fr
Not yet fixed in build of Apr 27 2006 08:15:12, above code still fails.
 [2006-04-30 01:06 UTC] wez@php.net
Not a PHP bug; you cannot use CALL with the native prepared statement API in mySQL.

Use the latest snapshot or PHP 5.1.3 (being released any day now) and follow the advice in:
http://netevil.org/node.php?nid=795


 [2006-04-30 10:43 UTC] brice dot joly at free dot fr
Some quick clarification: the problem occurs even with non-prepared code:

$dbh = new PDO('mysql:host=localhost;dbname=test', 'user', 'password',
array(PDO::ATTR_PERSISTENT => true);

foreach ($dbh->query("CALL simpleTest()") as $row) {
    print_r($row);
}
$arr = $dbh->errorInfo();
print_r($arr);

So I'm afraid the problem is not directly linked with the native prepared statement API, though the people at that conference might know better.
 [2006-04-30 13:34 UTC] wez@php.net
Please read my comments again, carefully.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC