From:             edoardo at wbr dot it
Operating system: Linux
PHP version:      4.4.4
PHP Bug Type:     MySQL related
Bug description:  Commands out of sync error when calling MySQL stored 
procedures from PHP

Description:
------------
>From PHP I cannot call two stored procedure in the same connection (I
guess it depends on the fact they are returning MULTI_RESULTS, it doesn't
happen with normal SELECTs)

When I run the second one I get the following error: "Commands out of
sync; you can't run this command now".

I made a lot of tests with different MySQL versions, at the moment I'm
running a 5.0.27 built from source and PHP 4.4.4 built from source and
linked to 5.0.27 (not using the bundled library) and I get that error but,
for example, I got it working with client libraries from MySQL 5.1.7 beta
(but not with 5.1.12 beta).

I already posted this bug to MySQL but they closed it telling it's not a
bug (http://bugs.mysql.com/?id=24783).
They pointed me at
http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
but I cannot find a PHP equivalent for mysql_next_result


Reproduce code:
---------------
#!/usr/bin/php -q
<?php
define('CLIENT_MULTI_RESULTS', 131072);

$conn = mysql_connect("localhost", "root", "", 1 , CLIENT_MULTI_RESULTS)
or die(mysql_error());
mysql_select_db("tester") or die(mysql_error());

$query = "CALL test_proc('webrainstorm')";

for ($i = 1; $i < 5; $i++) {
        $ret = mysql_unbuffered_query($query) or
die(mysql_error()."\n");
        while ($row = mysql_fetch_array($ret, MYSQL_ASSOC)) {
                foreach ($row as $col) {
                        echo "$col\t";
                }
                echo "\n";
        }
        mysql_free_result($ret);
        unset($ret);
}

mysql_close($conn);
?>

Find SQL test script at http://www.webrainstorm.it/tmp/test.sql

Expected result:
----------------
# ./test.php
enabled
enabled
enabled
enabled

Actual result:
--------------
# ./test.php
enabled
Commands out of sync; you can't run this command now

-- 
Edit bug report at http://bugs.php.net/?id=39727&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39727&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39727&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39727&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39727&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39727&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39727&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39727&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39727&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39727&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39727&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39727&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39727&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39727&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39727&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39727&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39727&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39727&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39727&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39727&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39727&r=mysqlcfg

Reply via email to