Bug #11904 mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY grouping wrong result
Submitted: 13 Jul 2005 9:26 Modified: 27 Aug 2005 19:15
Reporter: Berto van de Kraats Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.10-beta OS:Linux (Linux)
Assigned to: Andrey Hristov CPU Architecture:Any

[13 Jul 2005 9:26] Berto van de Kraats
If cursors are enabled, a query containing a group by clause gives a wrong result (it repeats the same data, the number of rows is correct though).

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 many calls to mysql_stmt_fetch that each return the same data (search for the pattern "ERROR:" in attached program).
[13 Jul 2005 9:28] Berto van de Kraats
Cpp trace of problem

Attachment: bug11904.cpp (text/plain), 25.47 KiB.

[13 Jul 2005 18:10] Jorge del Conde
Thanks for your excellent bug report Peter.  I was able to reproduce this bug using 5.0.10bk.
[22 Jul 2005 15:30] Andrey Hristov
Cannot repeat. Linux, MySQL 5.0.10-beta, MySQL 5.1.0-alpha.
Combinations :
Server Client
50010  50010
50010  50100
50100  50100
[16 Aug 2005 14:38] Berto van de Kraats
I've downloaded 5.0.12-beta 0812 and now this problem is reproducible again.
The attached program (bug11940b.cpp) should run silently if the bug does not repeat. If the bug repeats then the following is printed:

!!! Error. Line 253
  Expected value:[Int]"20",[Str]"PL2100"
  Returned value:[Int]"10",[Str]"AD3100"
a.out: bug.cpp:253: int main(): Assertion `0' failed.
Abort (core dumped) 

If you remove the mysql_stmt_attr_set() statement then the problem does not occur.
[16 Aug 2005 14:38] Berto van de Kraats
Trace showing problem

Attachment: bug11904b.ccp (text/plain), 29.15 KiB.

[16 Aug 2005 15:33] Andrey Hristov
I ran your new test case here with 5.0.12 from this afternoon and it run without any assert to be raised.
[16 Aug 2005 15:38] Andrey Hristov
Reproduced on a 64bit. Berto, on what platform does your MySQL installation run?
[17 Aug 2005 6:58] Berto van de Kraats
Our installation runs on SUSE SLES 9 (which is 32 bit).
[25 Aug 2005 15:33] Andrey Hristov
a shorter repro case (the primary key is mandatory or the query won't fail)

Attachment: bug11904_our.c (text/x-csrc), 2.51 KiB.

[26 Aug 2005 7:46] 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:

[27 Aug 2005 19:15] Paul DuBois
Noted in 5.0.13 changelog.