#40852 [NEW]: prepared statement in a stored procedure mess up bind_result() parameters
| From: | phpbugs at mise dot x25 dot se | Date: | Mon, 19 Mar 2007 00:04:20 +0000 |
| Subject: | #40852 [NEW]: prepared statement in a stored procedure mess up bind_result() parameters | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-110490@lists.php.net to get a copy of this message | ||
From: phpbugs at mise dot x25 dot se
Operating system: winXP
PHP version: 5CVS-2007-03-19 (snap)
PHP Bug Type: MySQLi related
Bug description: prepared statement in a stored procedure mess up bind_result() parameters
Description:
------------
Using a prepared statement in a stored procedure in MySQL 5 mess up
bind_result() parameters. The prepared statement can be anything, it seems.
Reproduce code:
---------------
- create a stored procedure in the mysql test database
DELIMITER $$
DROP PROCEDURE IF EXISTS test.spTest$$
CREATE PROCEDURE test.spTest()
BEGIN
PREPARE statement FROM "SET @x = 123";
EXECUTE statement;
DEALLOCATE PREPARE statement;
SELECT 5, 8;
END$$
- then call it from PHP like this
<?php
$mysqli = new mysqli("localhost", "user", "pwd", "test");
$statement = $mysqli->prepare("CALL spTest()");
$statement->execute();
$statement->bind_result($a, $b);
$statement->fetch();
print "a = $a, b = $b";
?>
Expected result:
----------------
Expected result
a = 5, b = 8
we can confirm this by doing:
mysql> call spTest();
+---+---+
| 5 | 8 |
+---+---+
| 5 | 8 |
+---+---+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
(moving "SELECT 5, 8" above EXECUTE in the stored procedure yield the
expected result)
Actual result:
--------------
Actual result (in this case):
a = , b = 15763698207438849
but depending on a variety of unknown factors the bound result can be
complete garble as well.
--
Edit bug report at http://bugs.php.net/?id=40852&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40852&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40852&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40852&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40852&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40852&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40852&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40852&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40852&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40852&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40852&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40852&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40852&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40852&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40852&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40852&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40852&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40852&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40852&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40852&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40852&r=mysqlcfg