[ODBC-19] Using same pointer as StrLen_Or_IndPtr for several coulmns, may cause errors if one of columns bound as SQL_C_WCHAR Created: 2015-03-11  Updated: 2015-05-30  Resolved: 2015-03-12

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Lawrin Novitsky Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None


 Description   

The testcase. In this case strings get truncated.
ODBC_TEST(same_len_ptr_binding)
{
SQLLEN lenPtr;
SQLWCHAR a[10], b[10], c[10];
SQLWCHAR a_ref[]=

{'M', 'a', 'r', 'i', 'a', 'D', 'B', 0}

, c_ref[]=

{'S', 'k', 'y', 0}

;

a[0]= b[0]= c[0]= 0;

OK_SIMPLE_STMT(Stmt, "DROP table IF EXISTS t_odbc19");

OK_SIMPLE_STMT(Stmt, "CREATE table t_odbc19(a varchar(10), b varchar(10), c varchar(10))");

OK_SIMPLE_STMT(Stmt, "insert into t_odbc19(a, c) values( 'MariaDB', 'Sky')");

OK_SIMPLE_STMTW(Stmt, L"select a, b, c from t_odbc19");

CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 1, SQL_C_WCHAR, a, sizeof(a), &lenPtr));
CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 2, SQL_C_WCHAR, b, sizeof(b), &lenPtr));
CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 3, SQL_C_WCHAR, c, sizeof(c), &lenPtr));

CHECK_STMT_RC(Stmt, SQLFetch(Stmt));

IS_WSTR(a, a_ref, sizeof(a_ref)/sizeof(SQLWCHAR));
IS_WSTR(c, c_ref, sizeof(a_ref)/sizeof(SQLWCHAR));

CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

OK_SIMPLE_STMT(Stmt, "DROP table t_odbc19");

return OK;
}



 Comments   
Comment by Lawrin Novitsky [ 2015-03-12 ]

The testcase and the fix have been pushed to the master branch, commit dc3068121a9115e9a7a0ba20a0ebef2d60790986

Generated at Thu Feb 08 03:25:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.