=== modified file 'ChangeLog' --- ChangeLog 2012-11-30 14:57:50 +0000 +++ ChangeLog 2012-12-13 14:36:49 +0000 @@ -7,6 +7,7 @@ (Bug# 11766724/59900) * Corrected calculation for length indicator descriptor field (Bug# 11766437) * is_minimum_version() function does not work correctly (Bug# 15926340) + * Problem with BIT columns in MS Access (Bug# 15997361/67702) ---- === modified file 'driver/execute.c' --- driver/execute.c 2012-11-30 14:57:50 +0000 +++ driver/execute.c 2012-12-13 14:32:18 +0000 @@ -107,6 +107,16 @@ { native_error= mysql_stmt_execute(stmt->ssps); } + else + { + set_stmt_error(stmt,mysql_stmt_sqlstate(stmt->ssps), + mysql_stmt_error(stmt->ssps), + mysql_stmt_errno(stmt->ssps)); + + translate_error(mysql_stmt_sqlstate(stmt->ssps), MYERR_S1000, + mysql_stmt_errno(stmt->ssps)); + goto exit; + } MYLOG_QUERY(stmt, "ssps has been executed"); } else @@ -753,6 +763,7 @@ switch ( aprec->concise_type ) { + case SQL_C_BINARY: case SQL_C_CHAR: convert= 1; @@ -975,6 +986,13 @@ goto out; + case SQL_BIT: + { + char bit_val= atoi(data); + /* Generic ODBC supports only BIT(1) */ + bind_param(bind, &bit_val, 1, MYSQL_TYPE_TINY); + goto out; + } case SQL_FLOAT: case SQL_REAL: case SQL_DOUBLE: === modified file 'test/my_prepare.c' --- test/my_prepare.c 2012-11-26 12:13:08 +0000 +++ test/my_prepare.c 2012-12-13 14:32:30 +0000 @@ -1123,6 +1123,63 @@ } +/** + Bug #67702: Problem with BIT columns in MS Access +*/ +DECLARE_TEST(t_bug67702) +{ + SQLCHAR data1[5]= "abcd"; + char c1 = 1, c2= 0; + int id= 1; + + SQLLEN paramlen= 0; + + ok_stmt(hstmt, SQLExecDirect(hstmt, "drop table if exists bug67702", + SQL_NTS)); + + ok_stmt(hstmt, SQLExecDirect(hstmt, "create table bug67702"\ + "(id int auto_increment primary key,"\ + "vc varchar(32), yesno bit(1))", + SQL_NTS)); + + ok_stmt(hstmt, SQLExecDirect(hstmt, "INSERT INTO bug67702(id, vc, yesno)"\ + "VALUES (1, 'abcd', 1)", + SQL_NTS)); + + /* Set parameter values here to make it clearer where each one goes */ + c1= 0; + ok_stmt(hstmt, SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_BIT, + SQL_BIT, 1, 0, &c1, 0, NULL)); + + id= 1; + ok_stmt(hstmt, SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, + SQL_INTEGER, sizeof(id), 0, &id, 0, NULL)); + + paramlen= 4; + ok_stmt(hstmt, SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, + SQL_VARCHAR, 4, 0, data1, 0, ¶mlen)); + + c2= 1; + ok_stmt(hstmt, SQLBindParameter(hstmt, 4, SQL_PARAM_INPUT, SQL_C_BIT, + SQL_BIT, 1, 0, &c2, 0, NULL)); + + /* The prepared query looks exactly as MS Access does it */ + ok_stmt(hstmt, SQLExecDirect(hstmt, "UPDATE `bug67702` SET `yesno`=? "\ + "WHERE `id` = ? AND `vc` = ? AND "\ + "`yesno` = ?", SQL_NTS)); + SQLFreeStmt(hstmt, SQL_CLOSE); + + /* Now check the result of update the bit field should be set to 0 */ + ok_stmt(hstmt, SQLExecDirect(hstmt, "SELECT `yesno` FROM `bug67702`", SQL_NTS)); + ok_stmt(hstmt, SQLFetch(hstmt)); + is(my_fetch_int(hstmt, 1) == 0); + + SQLFreeStmt(hstmt, SQL_CLOSE); + ok_stmt(hstmt, SQLExecDirect(hstmt, "drop table if exists bug67702", SQL_NTS)); + return OK; +} + + BEGIN_TESTS ADD_TEST(t_prep_basic) ADD_TEST(t_prep_buffer_length) @@ -1139,6 +1196,7 @@ ADD_TEST(t_acc_update) ADD_TEST(t_bug29871) ADD_TEST(t_bug67340) + ADD_TEST(t_bug67702) END_TESTS