=== modified file 'driver/results.c' --- driver/results.c 2008-08-22 22:12:25 +0000 +++ driver/results.c 2008-09-25 07:31:31 +0000 @@ -193,7 +193,7 @@ case SQL_C_BIT: if (rgbValue) { - if (value[0] == 1 || !atoi(value)) + if (value[0] && value[0] != '0') *((char *)rgbValue)= 1; else *((char *)rgbValue)= 0; === modified file 'test/my_result.c' --- test/my_result.c 2008-08-22 22:12:25 +0000 +++ test/my_result.c 2008-09-25 08:29:48 +0000 @@ -2437,6 +2437,47 @@ } +/* + Bug 39644 - Binding SQL_C_BIT to an integer column is not working + */ +DECLARE_TEST(t_bug39644) +{ + char col1 = 0x3f; + char col2 = 0xff; + char col3 = 0x0; + char col4 = 0x1; + + ok_sql(hstmt, "drop table if exists t_bug39644"); + ok_sql(hstmt, "create table t_bug39644(col1 INT, col2 INT,"\ + "col3 BIT, col4 BIT)"); + + ok_sql(hstmt, "insert into t_bug39644 VALUES (5, 0, 1, 0)"); + + /* Do SELECT */ + ok_sql(hstmt, "SELECT * from t_bug39644"); + + /* Now bind buffers */ + ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_BIT, &col1, sizeof(char), 0)); + ok_stmt(hstmt, SQLBindCol(hstmt, 2, SQL_C_BIT, &col2, sizeof(char), 0)); + ok_stmt(hstmt, SQLBindCol(hstmt, 3, SQL_C_BIT, &col3, sizeof(char), 0)); + ok_stmt(hstmt, SQLBindCol(hstmt, 4, SQL_C_BIT, &col4, sizeof(char), 0)); + + /* Fetch and check results */ + ok_stmt(hstmt, SQLFetch(hstmt)); + + is( col1 == 1 ); + is( col2 == 0 ); + is( col3 == 1 ); + is( col4 == 0 ); + + /* Clean-up */ + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + ok_sql(hstmt, "drop table t_bug39644"); + + return OK; +} + + BEGIN_TESTS ADD_TEST(my_resultset) ADD_TEST(t_convert_type) @@ -2474,6 +2515,7 @@ ADD_TEST(t_bug34575) ADD_TEST(t_bug24131) ADD_TEST(t_bug36069) + ADD_TEST(t_bug39644) END_TESTS