diff -rN -u old-odbc3/ChangeLog new-odbc3/ChangeLog --- old-odbc3/ChangeLog 2007-07-10 16:20:10.000000000 -0500 +++ new-odbc3/ChangeLog 2007-07-10 16:20:10.000000000 -0500 @@ -32,6 +32,9 @@ dates as the minimum allowed ODBC date (XXXX-01-01). Added another option (FLAG_MIN_DATE_TO_ZERO) to mirror this but for bound parameters. FLAG_MIN_DATE_TO_ZERO only changes 0000-01-01 to 0000-00-00. (Bug #13766) + * Fixed possible crash if SQLBindCol() was not called before SQLSetPos(). + Fixed use of MYSQL structure pertaining to updating large blobs in + cursors. (Bug #10562) ---- diff -rN -u old-odbc3/driver/cursor.c new-odbc3/driver/cursor.c --- old-odbc3/driver/cursor.c 2007-07-10 16:20:10.000000000 -0500 +++ new-odbc3/driver/cursor.c 2007-07-10 16:20:10.000000000 -0500 @@ -818,7 +818,7 @@ field= mysql_fetch_field_direct(result,ncol); bind= stmt->bind+ncol; - if ( bind && !bind->field ) + if (!stmt->bind || (bind && !bind->field)) { ignore_count++; continue; @@ -1129,8 +1129,7 @@ SQLUINTEGER insert_count= 1; /* num rows to insert - will be real value when row is 0 (all) */ SQLUINTEGER count= 0; /* current row */ SQLLEN length; - MYSQL mysql= stmt->dbc->mysql; - NET *net= &mysql.net; + NET *net= &stmt->dbc->mysql.net; SQLUSMALLINT ncol; SQLCHAR *to; ulong query_length= 0; /* our original query len so we can reset pos if break_insert */ diff -rN -u old-odbc3/test/my_blob.c new-odbc3/test/my_blob.c --- old-odbc3/test/my_blob.c 2007-07-10 16:20:10.000000000 -0500 +++ new-odbc3/test/my_blob.c 2007-07-10 16:20:10.000000000 -0500 @@ -751,6 +751,40 @@ } +/* + * Bug #10562 - Large blobs fail in a cursor + */ +DECLARE_TEST(t_bug10562) +{ + SQLLEN bsize = 12 * 1024; + /* Test to just insert 12k blob */ + SQLCHAR *blob = malloc(bsize); + SQLCHAR *blobcheck = malloc(bsize); + memset(blob, 'X', bsize); + + ok_sql(hstmt, "drop table if exists t_bug10562"); + ok_sql(hstmt, "create table t_bug10562 ( id int not null primary key, mb longblob )"); + ok_sql(hstmt, "insert into t_bug10562 (mb) values ('zzzzzzzzzz')"); + + ok_stmt(hstmt, SQLExecDirect(hstmt, "select id, mb from t_bug10562", SQL_NTS)); + ok_stmt(hstmt, SQLFetch(hstmt)); + ok_stmt(hstmt, SQLBindCol(hstmt, 2, SQL_C_BINARY, blob, bsize, &bsize)); + ok_stmt(hstmt, SQLSetPos(hstmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE)); + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + /* Get the data back out to verify */ + ok_sql(hstmt, "select mb from t_bug10562"); + ok_stmt(hstmt, SQLFetch(hstmt)); + ok_stmt(hstmt, SQLGetData(hstmt, 1, SQL_C_BINARY, blobcheck, bsize, NULL)); + is(!memcmp(blob, blobcheck, bsize)); + + ok_sql(hstmt, "drop table if exists t_bug10562"); + free(blob); + free(blobcheck); + return OK; +} + + BEGIN_TESTS ADD_TEST(t_blob) ADD_TEST(t_1piecewrite2) @@ -762,6 +796,7 @@ ADD_TEST(t_text_fetch) ADD_TEST(getdata_lenonly) ADD_TEST(t_bug9781) + ADD_TEST(t_bug10562) END_TESTS