Bug #6293 Incorrect Return Value of mysql_more_results For Stored Procedures
Submitted: 27 Oct 2004 21:24 Modified: 7 Feb 2005 10:56
Reporter: Michael G. Zinner Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1 OS:Linux (Fedora Core 1, WinXP)
Assigned to: CPU Architecture:Any

[27 Oct 2004 21:24] Michael G. Zinner
Description:
Calling mysql_more_results(mysql); to find out if there are any resultsets left does not work if you are executing a stored procedure that returns several resultsets.

Either the documentation on http://dev.mysql.com/doc/mysql/en/mysql_more_results.html is wrong ot the return value.

It seems like this only works for CLIENT_MULTI_STATEMENTS, like 

SELECT "bla"; SELECT "ble";

at the moment. It always returns 1 even for the last resultset.

How to repeat:
Execute this script:

-- cut --
DELIMITER \\

DROP PROCEDURE IF EXISTS `test`.`simpleproc`\\
CREATE PROCEDURE `test`.`simpleproc`()
BEGIN
  SELECT 'TEST' AS Res1;
  SELECT 'TEST2' AS Res2;
  SELECT test.hello ('Alfredo') as Res3;
END\\

DELIMITER ;
-- cut --

and try to call the procedure from the C API.

Suggested fix:
Consider SPs as well.
[7 Feb 2005 10:56] Hartmut Holzgraefe
Using 5.0.3 and PHP mysqli_multi_query() and mysql_next_result() i get multiple  
result sets from a stored procedure just fine