Bug #11909 mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY nested queries corrupt result
Submitted: 13 Jul 2005 11:24 Modified: 14 Aug 2005 0:39
Reporter: Berto van de Kraats Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.10-beta OS:Linux (Linux)
Assigned to: Konstantin Osipov CPU Architecture:Any

[13 Jul 2005 11:24] Berto van de Kraats
Description:
If cursors are enabled, and queries on the same table are nested then the outer query returns corrupt data.

How to repeat:
Compile and run the attached program (which is an automatically generated trace of our mysql database driver). The problem reproduces if the program silently runs and has exit status 0.

The trace contains a call to mysql_stmt_fetch that returns corrupted data (search for pattern "ERROR:" in attached program).
[13 Jul 2005 11:25] Berto van de Kraats
Cpp trace of problem

Attachment: bug11909.cpp (text/plain), 29.68 KiB.

[13 Jul 2005 12:00] Berto van de Kraats
Another cpp trace of the problem

Attachment: bug11902.cpp (text/plain), 26.92 KiB.

[13 Jul 2005 18:11] Jorge del Conde
Thanks for your excellent bug report Peter.  I was able to reproduce this bug using 5.0.10bk.
[22 Jul 2005 18:04] Andrey Hristov
there is off-by-1 problem. the problem is that the pointer in the row advances one position more than needed and then the beginning of a text string is read as it's length and then the data is corrupted. when run in debugger and manually move the pointer with 1 byte behind everything is fine. I will continue investigating where exactly the problem is created.
[22 Jul 2005 18:05] Andrey Hristov
assigning to me
[3 Aug 2005 18:19] 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/internals/27856
[8 Aug 2005 15:05] 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/internals/28000
[8 Aug 2005 15:32] Konstantin Osipov
Pushed into 5.0 tree, tagged 5.0.12
[14 Aug 2005 0:39] Paul DuBois
Noted in 5.0.12 changelog.