Bug #39858 [ReO]: Lost connection to MySQL server during query by a repeated call stored proced

From: Date: Tue, 25 Feb 2014 14:18:51 +0000
Subject: Bug #39858 [ReO]: Lost connection to MySQL server during query by a repeated call stored proced
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184418@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=39858&edit=1

 ID:                 39858
 Updated by:         uw@php.net
 Reported by:        develar at gmail dot com
 Summary:            Lost connection to MySQL server during query by a
                     repeated call stored proced
 Status:             Re-Opened
 Type:               Bug
 Package:            PDO MySQL
 Operating System:   *
 PHP Version:        5.2.0
 Block user comment: N
 Private report:     N

 New Comment:

Core test code works just fine for me using mysqlnd from 

nixnutz@linux-dstv:~/src/php-src> sapi/cli/php -v
PHP 5.4.26-dev (cli) (built: Feb 11 2014 09:32:10) (DEBUG)


Getting this from emulation:

array(1) {
  [0]=>
  array(1) {
    ["2 * 2"]=>
    string(1) "4"
  }
}
array(0) {
}
array(1) {
  [0]=>
  array(1) {
    ["2 * 2"]=>
    string(1) "4"
  }
}
array(0) {
}


... and the very same from native PS. Code is the one from the test:

  $db->exec("DROP PROCEDURE IF EXISTS p");
        $db->exec("
                CREATE PROCEDURE p()
                        NOT DETERMINISTIC
                        CONTAINS SQL
                        SQL SECURITY DEFINER
                        COMMENT ''
                BEGIN
                        SELECT 2 * 2;
                END;");

        $stmt = $db->prepare("CALL p()");
        $stmt->execute();
        do {
                var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
        } while ($stmt->nextRowset());

        $stmt = $db->prepare("CALL p()");
        $stmt->execute();
        do {
                var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
        } while ($stmt->nextRowset());


So if there is an issue, someone should write a comprehensive test different from the bug39858 test
and provide it. Otherwise it is: can't repeat with recent versions of PHP and MySQL.


Previous Comments:
------------------------------------------------------------------------
[2014-01-14 22:11:31] gvinaj at hush dot ai

Still seeing this issue with Yii framework migrations.
Win2008R2 x64, IIS7.5, PHP5.4.9 (tried also 5.5.3), MySQL 5.7.3-m13
Seeing the following error while running Yii migrations that include multiple SQL statements against
MySQL:
"Fatal error: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other
unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code
is only ever going to run against mysql, you may enable query buffering by setting the
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute..."

For some reason even the suggested setup with 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY=true'
attribute is not working for me.
Any suggested workaround or idea why is not working?

------------------------------------------------------------------------
[2013-08-11 03:39:36] stas@php.net

Still seeing this problem in test bug_39858. See:

https://travis-ci.org/php/php-src/builds/10062028

and also on my local Linux, 64-bit, produces this on master:

Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in 
/home/smalyshev/php-src/ext/pdo_mysql/tests/bug_39858.php on line 22

Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in 
/home/smalyshev/php-src/ext/pdo_mysql/tests/bug_39858.php on line 28

------------------------------------------------------------------------
[2008-09-12 23:02:00] johannes@php.net

This bug has been fixed in CVS.

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.

Fixed when using mysqlnd (Windows default, else, --with-pdo-mysql=mysqlnd)

------------------------------------------------------------------------
[2008-08-28 09:34:01] sakha5413 at gmail dot com

Fatal error: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered
queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only
ever going to run against mysql, you may enable query buffering by setting the
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in
C:\xampp\htdocs\tshirtshop\business\database_handler.php on line 102

------------------------------------------------------------------------
[2008-07-21 15:06:16] jpmasseria at hotmail dot com

The single line workaround worked for me!

	while (mysqli_next_result($conn));

Thank you bepoteat!

This is much better than my previous workaround which was to close and reopen my database connection
before my subsequent stored procedure call.

John

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=39858


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=39858&edit=1


Thread (44 messages)

« previous php.bugs (#184418) next »