=== modified file 'driver/ansi.c' --- driver/ansi.c 2010-01-31 00:29:06 +0000 +++ driver/ansi.c 2010-07-29 10:16:44 +0000 @@ -79,7 +79,12 @@ SQLColAttributeImpl(SQLHSTMT hstmt, SQLUSMALLINT column, SQLUSMALLINT field, SQLPOINTER char_attr, SQLSMALLINT char_attr_max, SQLSMALLINT *char_attr_len, - SQLLEN *num_attr) +#ifdef USE_SQLCOLATTRIBUTE_SQLLEN_PTR + SQLLEN *num_attr +#else + SQLPOINTER num_attr +#endif + ) { STMT *stmt= (STMT *)hstmt; SQLCHAR *value= NULL; === modified file 'driver/results.c' --- driver/results.c 2010-04-30 13:20:44 +0000 +++ driver/results.c 2010-07-29 11:39:26 +0000 @@ -802,7 +802,13 @@ */ SQLRETURN SQL_API MySQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT column, - SQLUSMALLINT attrib, SQLCHAR **char_attr, SQLLEN *num_attr) + SQLUSMALLINT attrib, SQLCHAR **char_attr, +#ifdef USE_SQLCOLATTRIBUTE_SQLLEN_PTR + SQLLEN *num_attr +#else + SQLPOINTER num_attr +#endif + ) { STMT *stmt= (STMT *)hstmt; SQLLEN nparam= 0; @@ -833,7 +839,7 @@ if (attrib == SQL_DESC_COUNT || attrib == SQL_COLUMN_COUNT) { - *num_attr= stmt->ird->count; + *(SQLLEN *)num_attr= stmt->ird->count; return SQL_SUCCESS; } @@ -882,7 +888,14 @@ case SQL_DESC_UNSIGNED: case SQL_DESC_UPDATABLE: error= stmt_SQLGetDescField(stmt, stmt->ird, column, attrib, - num_attr, SQL_IS_INTEGER, NULL); +#ifdef USE_SQLCOLATTRIBUTE_SQLLEN_PTR + (SQLPOINTER)num_attr, + SQL_IS_LEN, +#else + num_attr, + SQL_IS_INTEGER, +#endif + NULL); break; case SQL_DESC_DISPLAY_SIZE: === modified file 'driver/unicode.c' --- driver/unicode.c 2010-01-31 00:29:06 +0000 +++ driver/unicode.c 2010-07-29 10:16:02 +0000 @@ -82,7 +82,12 @@ SQLColAttributeWImpl(SQLHSTMT hstmt, SQLUSMALLINT column, SQLUSMALLINT field, SQLPOINTER char_attr, SQLSMALLINT char_attr_max, SQLSMALLINT *char_attr_len, - SQLLEN *num_attr) +#ifdef USE_SQLCOLATTRIBUTE_SQLLEN_PTR + SQLLEN *num_attr +#else + SQLPOINTER num_attr +#endif + ) { STMT *stmt= (STMT *)hstmt; SQLCHAR *value= NULL; === modified file 'test/my_result.c' --- test/my_result.c 2010-03-24 08:44:10 +0000 +++ test/my_result.c 2010-08-06 09:20:57 +0000 @@ -2607,6 +2607,58 @@ } +/* + Bug 55024 - Wrong type returned by SQLColAttribute(SQL_DESC_PRECISION...) in 64-bit Linux + */ +DECLARE_TEST(t_bug55024) +{ + SQLSMALLINT len; + SQLLEN res; + + ok_stmt(hstmt, SQLExecDirect(hstmt, "DROP TABLE IF EXISTS t_test55024", SQL_NTS)); + + ok_stmt(hstmt, SQLExecDirect(hstmt, "CREATE TABLE t_test55024(col01 LONGTEXT, "\ + "col02 BINARY(16),"\ + "col03 VARBINARY(16),"\ + "col04 LONGBLOB,"\ + "col05 BIGINT,"\ + "col06 TINYINT,"\ + "col07 BIT, col08 DOUBLE"\ + ");", SQL_NTS)); + + ok_stmt(hstmt, SQLExecDirect(hstmt, "INSERT INTO t_test55024 VALUES ('a', 'b', 'c', 'd', 999, 111, 3, 3.1415)", SQL_NTS)); + + + ok_stmt(hstmt, SQLExecDirect(hstmt, "SELECT * FROM t_test55024", SQL_NTS)); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 1, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_LONGVARCHAR); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 2, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_BINARY); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 3, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_VARBINARY); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 4, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_LONGVARBINARY); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 5, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_BIGINT); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 6, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_TINYINT); + + ok_stmt(hstmt, SQLColAttribute(hstmt, 7, SQL_DESC_TYPE, NULL, 0, &len, &res)); + is_num(res, SQL_BIT); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + + ok_sql(hstmt, "DROP TABLE IF EXISTS t_bug55024"); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_resultset) ADD_TEST(t_convert_type) @@ -2647,6 +2699,7 @@ ADD_TEST(t_bug32821) ADD_TEST(t_bug34271) ADD_TEST(t_bug32684) + ADD_TEST(t_bug55024) END_TESTS