Bug #14013 mysql_stmt_store_result() bombs if a cursor is open
Submitted: 13 Oct 2005 18:30 Modified: 15 Feb 2006 20:36
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Prepared statements Severity:S3 (Non-critical)
Version:5.0.x OS:Any (ALL)
Assigned to: Magnus Blåudd CPU Architecture:Any

[13 Oct 2005 18:30] Paul DuBois
Description:
If no cursor is open on a prepared statement, the sequence
of calls, mysql_stmt_execute(), mysql_stmt_store_result(),
mysql_stmt_fetch() works.

But if you open a cursor on the prepared statement first, the
same sequence of calls results in the following error for
mysql_stmt_store_result():

Error 2014 (HY000): Commands out of sync; you can't run this command now

Removing the mysql_stmt_store_result() call results in normal
execution.

How to repeat:
See above.
[14 Oct 2005 14:46] Valeriy Kravchuk
Would you, please, provide a complete test case. Looks like you have one already.
[14 Oct 2005 19:13] Paul DuBois
bug-14013.c

Attachment: bug-14013.c (application/octet-stream, text), 6.65 KiB.

[14 Oct 2005 19:14] Paul DuBois
Please see uploaded file, bug-14013.c.
[14 Oct 2005 23:40] MySQL Verification Team
Thank you for the bug report.

miguel@hegel:~/dbs/5.0> ./bug14013 
Could not buffer result set
Error 2014 (HY000): Commands out of sync; you can't run this command now
[2 Feb 2006 11:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/2060
[10 Feb 2006 13:02] Konstantin Osipov
Approved my email with a view review comments.
[10 Feb 2006 13:50] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/2445
[15 Feb 2006 20:05] Magnus Blåudd
Pushed a fix to 5.0.19 that makes it possible to use 'mysql_stmt_store_result' on a prepared statement with server side cursor.
[15 Feb 2006 20:36] Paul DuBois
Noted in 5.0.19 changelog.
[15 Feb 2006 20:57] Mike Hillyer
Documented in 5.0.19 changelog:

<listitem>
        <para>
          A prepared statement that called
          <function>mysql_stmt_store_result</function> when a cursor was
          open caused an error. (Bug #14013)
        </para>
      </listitem>