ID:               48065
 Comment by:       schwern at pobox dot com
 Reported By:      schwern at pobox dot com
 Status:           Open
 Bug Type:         MySQLi related
 Operating System: OS X
 PHP Version:      5.2CVS-2009-04-23 (snap)
 New Comment:

For reference, here's the MySQL 5.0 docs on "Commands out of sync".
http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html


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

[2009-04-23 23:10:26] schwern at pobox dot com

Description:
------------
mysqli does not like having two query results active at the same time
if a stored procedure was queried.  MySQL balks with "Commands out of
sync; you can't run this command now".

The equivalent SELECT does not have this problem, nor does Perl's
DBD::mysql for comparison.

Work arounds appear to be explicitly free'ing the result before calling
the next one, but that is not easily possible through the Drupal DB API,
for example.  Also I might want to return a query result from a function
and have it live on out of my function's control.  And its a general
violation of OO to have the two result objects interfere with each
other.

Reproduce code:
---------------
http://rafb.net/p/XnP3AN31.html

(Writes to the test database and user)

The script creates a table with a few rows and a stored procedure doing
a "select *" on that table.  It then illustrates that two concurrent
calls to that procedure cause an error while two "SELECT *" queries do
not.

Replicated on OS X with their stock PHP 5.2.6 and a fresh
php5.2-200904232230 snapshot with --with-mysqli.

Using a local mysql server compiled from MacPorts.
mysql  Ver 14.12 Distrib 5.0.77, for apple-darwin9.6.0 (i386) using
readline 6.0


Expected result:
----------------
Doing call get_stuff
Done

Doing select * from stuff
Done


Actual result:
--------------
Doing call get_stuff
Second query FAILED: Commands out of sync; you can't run this command
now
Done

Doing select * from stuff
Done



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48065&edit=1

Reply via email to