|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-05-01 15:35 UTC] php at lummert dot net
[2014-05-06 08:22 UTC] johannes@php.net
-Status: Open
+Status: Not a bug
[2014-05-06 08:22 UTC] johannes@php.net
[2014-05-07 05:12 UTC] php at lummert dot net
[2014-05-07 08:26 UTC] johannes@php.net
[2014-05-07 11:29 UTC] php at lummert dot net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
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