Bug #67168 [NEW]: connection hangs after stored procedure call
| From: | php at lummert dot net | Date: | Thu, 01 May 2014 12:14:28 +0000 |
| Subject: | Bug #67168 [NEW]: connection hangs after stored procedure call | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185549@lists.php.net to get a copy of this message | ||
From: php at lummert dot net
Operating system: Windows 7
PHP version: 5.5.12
Package: MySQLi related
Bug Type: Bug
Bug description:connection hangs after stored procedure call
Description:
------------
Calling a stored procedure with rowset result yields the connection
corrupted as shown in example. Content of second query seems
unimportant, I always get the same error.
After first call to sp and consumption of rowset as shown, next_result()
method still yields true. store_result method returns no valid
resultset, though.
When store_result is called after first sp call and result use, the next
call actually succeeds, so this might be used as a workaraound.
Test script:
---------------
<?php
$con = new mysqli('127.0.0.1', 'root', 'Y@pack', 'uschi');
if ($con->connect_errno) { die('Failed to connect to database'); }
$con->query('DROP PROCEDURE IF EXISTS sp_test');
if ($con->errno) { die($con->error); }
$con->query('CREATE PROCEDURE sp_test() BEGIN SELECT 1 AS a, 2 AS b, 3
AS c; END');
if ($con->errno) { die($con->error); }
if ( ! ($res = $con->query('call sp_test()'))) { die($con->error); }
while ($row = $res->fetch_assoc()) {
echo $row['a'], ', ', $row['b'], ', ',
$row['c'];
}
$res->free_result();
echo '|';
if ( ! ($res = $con->query('SELECT 1 AS a, 2 AS b, 3 AS c;'))) {
die($con->error); }
while ($row = $res->fetch_assoc()) {
echo $row['a'], ', ', $row['b'], ', ',
$row['c'];
}
$res->free_result();
?>
--yields--> 1, 2, 3Commands out of sync; you can't run this command now
<?php
$con = new mysqli('127.0.0.1', 'root', 'Y@pack', 'uschi');
if ($con->connect_errno) { die('Failed to connect to database'); }
$con->query('DROP PROCEDURE IF EXISTS sp_test');
if ($con->errno) { die($con->error); }
$con->query('CREATE PROCEDURE sp_test() BEGIN SELECT 1 AS a, 2 AS b, 3
AS c; END');
if ($con->errno) { die($con->error); }
if ( ! ($res = $con->query('call sp_test()'))) { die($con->error); }
while ($row = $res->fetch_assoc()) {
echo $row['a'], ', ', $row['b'], ', ',
$row['c'];
}
$res->free_result();
// bug workaraound for stored procedures delivering a row set
if ($con->next_result()) { $res = $con->store_result(); }
echo '|';
if ( ! ($res = $con->query('SELECT 1 AS a, 2 AS b, 3 AS c;'))) {
die($con->error); }
while ($row = $res->fetch_assoc()) {
echo $row['a'], ', ', $row['b'], ', ',
$row['c'];
}
$res->free_result();
// bug workaraound for stored procedures delivering a row set
if ($con->next_result()) { $res = $con->store_result(); }
?>
--yields--> 1, 2, 3|1, 2, 3
Expected result:
----------------
1, 2, 3
Actual result:
--------------
1, 2, 3Commands out of sync; you can't run this command now
--
Edit bug report at https://bugs.php.net/bug.php?id=67168&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67168&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67168&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67168&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67168&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67168&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67168&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67168&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67168&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67168&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67168&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67168&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67168&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67168&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67168&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67168&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67168&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67168&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67168&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67168&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67168&r=mysqlcfg