Description:
Hi All,
Thanks you for fixing bug# 32684.
I just down loaded a snapshot of the MySQL Connector/ODBC 5.1: Alpha for Windows (built on 02/04/2008) and tested it with
our applications against MySQL 5.1.
However, SQLGetData now may give incorrect data in the second call to this function. Here is my test:
1) Create a table and populate this table:
create table test (pk int not null primary key, c1 varchar( 200 ));
insert into test values( 1, 'insert into test values( 1, 'abcdefghijklmnopqrstuvwxyz01234567898765a1b2c3d4e5f6g7h8i9jakblcmdneofpgqhrisjtk' );
2) Fetch the varchar column, c2 with
wchar_t buff[32];
SQLGetData( stmt, 2, SQL_C_WCHAR, buff, sizeof( buff ), &len );
Then SQLGetData will be called 3 times and we'll get 3 chunks of data. The first chunk seems okay and buff contains
abcdefghijklmnopqrstuvwxyz01234
The second chunk would be
4567898765a1b2c3d4e5f6g7h8i9jak
It is incorrect, because the first byte in the second chunk is the last byte in the first chunk.
I have run my little repro against MS SQL Server, Oracle, Sybase ASE and MySQL and the results are shown as below:
MS SQL Server
Test Begin ...
SQLFetch: ret = 0: row = 1, pk = 1, ind = 4
SQLGetData: ret = 1, len = 80, chunk = 1, buff = abcdefghijklmnopqrstuvwxyz01234
SQLGetData: ret = 1, len = 49, chunk = 2, buff = 567898765a1b2c3d4e5f6g7h8i9jakb
SQLGetData: ret = 0, len = 18, chunk = 3, buff = lcmdneofpgqhrisjtk
... Test End
Oracle
Test Begin ...
SQLFetch: ret = 0: row = 1, pk = 1, ind = 4
SQLGetData: ret = 1, len = 80, chunk = 1, buff = abcdefghijklmnopqrstuvwxyz01234
SQLGetData: ret = 1, len = 49, chunk = 2, buff = 567898765a1b2c3d4e5f6g7h8i9jakb
SQLGetData: ret = 0, len = 18, chunk = 3, buff = lcmdneofpgqhrisjtk
... Test End
Sybase ASE
Test Begin ...
SQLFetch: ret = 0: row = 1, pk = 1, ind = 4
SQLGetData: ret = 1, len = 80, chunk = 1, buff = abcdefghijklmnopqrstuvwxyz01234
SQLGetData: ret = 1, len = 49, chunk = 2, buff = 567898765a1b2c3d4e5f6g7h8i9jakb
SQLGetData: ret = 0, len = 18, chunk = 3, buff = lcmdneofpgqhrisjtk
... Test End
MySQL
Test Begin ...
SQLFetch: ret = 0: row = 1, pk = 1, ind = 4
SQLGetData: ret = 1, len = 80, chunk = 1, buff = abcdefghijklmnopqrstuvwxyz01234
SQLGetData: ret = 1, len = 49, chunk = 2, buff = 4567898765a1b2c3d4e5f6g7h8i9jak
SQLGetData: ret = 0, len = 18, chunk = 3, buff = blcmdneofpgqhrisjtk
... Test End
You'll see the results from MySQL are incorrect.
Thanks!
How to repeat:
A repro will be attached. Here are the steps to repro:
1) Unzip the zip file to a directory and you'll see there are 3 files: odbcbug.c, odbcbug.exe and output.
2) Run odbcbug.exe as
odbcbug "dsn=your_dsn;uid=your_login_id;pwd=your_password"
Then you'll see the problem.