Bug #73291 Can not fetch multiple results when executing procedure
Submitted: 14 Jul 2014 13:14 Modified: 17 Jul 2014 13:52
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:2.0.0 OS:Any
Assigned to: CPU Architecture:Any

[14 Jul 2014 13:14] Geert Vanderkelen
Description:
It is not possible to fetch multiple results when executing stored procedures using the MySQLCursor.execute() method.

How to repeat:
        self.cur = self.cnx.cursor()
        self.cur.execute("DROP PROCEDURE IF EXISTS multi_results")
        procedure = (
            "CREATE PROCEDURE multi_results () "
            "BEGIN SELECT 1; SELECT 'ham'; END"
        )
        self.cur.execute(procedure)
        stmt = "CALL multi_results()"
        exp_result = [[(1,)], [(u'ham',)]]
        results = []
        for result in self.cur.execute(stmt, multi=True):
            if result.with_rows:
                self.assertEqual(stmt, result._executed)
                results.append(result.fetchall())

        self.assertEqual(exp_result, results)
        self.cur.execute("DROP PROCEDURE multi_results")
[17 Jul 2014 13:52] Paul DuBois
Noted in 2.0.0 changelog.

For a stored procedure that produces multiple result sets, it is now
possible possible to execute the procedure and process its results by
executing a CALL statement. Execute the statement using execute()
with a multi=True argument, and use the returned iterator to process
each result in turn.