Index: ChangeLog =================================================================== --- ChangeLog (revision 853) +++ ChangeLog (working copy) @@ -8,6 +8,8 @@ applications, in order to work around a bug in ADO. (Bug #13776) Bugs fixed: + * Unsigned integer values greater than the maximum value of a signed + integer were handled incorrectly. (Bug #32171) * The wrong result was returned by SQLGetData() when the data was an empty string and a zero-sized buffer was specified. (Bug #30958) Index: driver/results.c =================================================================== --- driver/results.c (revision 853) +++ driver/results.c (working copy) @@ -209,7 +209,7 @@ case SQL_C_ULONG: if (rgbValue) - *((SQLUINTEGER *)rgbValue)= (SQLUINTEGER)atol(value); + *((SQLUINTEGER *)rgbValue)= (SQLUINTEGER)strtoul(value, NULL, 10); *pcbValue= sizeof(SQLUINTEGER); break; Index: test/my_types.c =================================================================== --- test/my_types.c (revision 853) +++ test/my_types.c (working copy) @@ -690,6 +690,37 @@ } +/** + Bug #32171: ODBC Driver incorrectly parses large Unsigned Integers +*/ +DECLARE_TEST(t_bug32171) +{ + SQLUINTEGER in= 4255080020, out; + SQLCHAR buff[128]; + + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug32171"); + ok_sql(hstmt, "CREATE TABLE t_bug32171 (a INT UNSIGNED)"); + + sprintf((char *)buff, "INSERT INTO t_bug32171 VALUES ('%lu')", in); + ok_stmt(hstmt, SQLExecDirect(hstmt, buff, SQL_NTS)); + + ok_sql(hstmt, "SELECT * FROM t_bug32171"); + + ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_ULONG, &out, 0, NULL)); + ok_stmt(hstmt, SQLFetch(hstmt)); + + is_num(out, in); + + expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug32171"); + + return OK; +} + + BEGIN_TESTS ADD_TEST(t_longlong1) ADD_TEST(t_numeric) @@ -704,6 +735,7 @@ ADD_TEST(binary_suffix) ADD_TEST(float_scale) ADD_TEST(bit) + ADD_TEST(t_bug32171) END_TESTS