From: phpbug at smithii dot com Operating system: Windows XP SP3 & Debian 4.0 PHP version: 5.2.9 PHP Bug Type: MySQLi related Bug description: Anomalous results from stored procedure with a PREPAREd statement
Description: ------------ Using MySQL 5.0.77, and calling a stored procedure with a PREPAREd statement, execute()/bind_result()/fetch() return anomalous results. Reproduce code: --------------- Using MySQL 5.0.77, and calling any stored procedure with a PREPAREd statement, such as: DROP PROCEDURE IF EXISTS echo; DELIMITER // CREATE PROCEDURE echo(p VARCHAR(255)) BEGIN SET @sql = CONCAT('SELECT ',QUOTE(p)); PREPARE stmt FROM @sql; EXECUTE stmt; DROP PREPARE stmt; END; // DELIMITER ; via this script: <?php $mysqli = new mysqli('localhost', 'root', '', 'test'); $sql = 'CALL echo(?)'; $s = $mysqli->prepare($sql); $i = $argv[1]; printf("i=%s\n", $i); $s->bind_param('s', $i); $s->execute(); $s->bind_result($o); while ($s->fetch()) { printf("o=%s (%s)\n", $o, bin2hex($o)); } $s->close(); produces anomalous results at least 50% of the time. For example: $ php echo.php abcd i=abcd o=cd ⦠(6364000004) If I remove the PREPAREd statement: DROP PROCEDURE IF EXISTS echo; DELIMITER // CREATE PROCEDURE echo(p VARCHAR(255)) BEGIN SELECT p; END; // DELIMITER ; everything works fine. Replacing execute()/bind_result()/fetch(), with query()/fetch_assoc() also fixes the issue. Other details: mysqli_get_client_info=5.0.51a mysqli_get_client_version=50051 mysqli_get_server_info=5.0.77-community-nt mysqli_get_server_version=50077 mysqli_get_host_info=localhost via TCP/IP mysqli_get_proto_info=10 Expected result: ---------------- $ php echo.php abcd i=abcd o=abcd (63646566) Actual result: -------------- $ php echo.php abcd i=abcd o=cd ⦠(6364000004) -- Edit bug report at http://bugs.php.net/?id=47782&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47782&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47782&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47782&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47782&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47782&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47782&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47782&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47782&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47782&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47782&r=support Expected behavior: http://bugs.php.net/fix.php?id=47782&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47782&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47782&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47782&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47782&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47782&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47782&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47782&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47782&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47782&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47782&r=mysqlcfg