ID:               40852
 Updated by:       [EMAIL PROTECTED]
 Reported By:      phpbugs at mise dot x25 dot se
-Status:           Open
+Status:           Assigned
 Bug Type:         MySQLi related
 Operating System: winXP
 PHP Version:      5CVS-2007-03-19 (snap)
-Assigned To:      
+Assigned To:      andrei
 New Comment:

Andrei, is this ext/mysqli or MySQL issue?


Previous Comments:
------------------------------------------------------------------------

[2007-03-19 00:04:20] phpbugs at mise dot x25 dot se

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 this bug report at http://bugs.php.net/?id=40852&edit=1

Reply via email to