Index: driver/utility.c =================================================================== --- driver/utility.c (revision 1010) +++ driver/utility.c (working copy) @@ -1194,6 +1194,9 @@ case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: + if (field->charsetnr != BINARY_CHARSET_NUMBER) + return get_display_size(stmt, field); + case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: Index: driver/myutil.h =================================================================== --- driver/myutil.h (revision 1010) +++ driver/myutil.h (working copy) @@ -89,8 +89,9 @@ {(name), (name), NullS, NullS, NullS, NullS, NullS, 11, 11, 0, 0, 0, 0, 0, \ 0, 0, (flags), 0, 0, MYSQL_TYPE_LONG, NULL} #elif MYSQL_VERSION_ID >= 40100 +/* we use 3 here as SYSTEM_CHARSET_MBMAXLEN is not defined in v5.0 mysql_com.h */ # define MYODBC_FIELD_STRING(name, len, flags) \ - {(name), (name), NullS, NullS, NullS, NullS, NullS, (len), 0, 0, 0, 0, 0, 0, \ + {(name), (name), NullS, NullS, NullS, NullS, NullS, (len) * 3, 0, 0, 0, 0, 0, 0, \ 0, 0, (flags), 0, UTF8_CHARSET_NUMBER, MYSQL_TYPE_VAR_STRING} # define MYODBC_FIELD_SHORT(name, flags) \ {(name), (name), NullS, NullS, NullS, NullS, NullS, 5, 5, 0, 0, 0, 0, 0, 0, \ Index: test/my_catalog.c =================================================================== --- test/my_catalog.c (revision 1010) +++ test/my_catalog.c (working copy) @@ -1194,6 +1194,30 @@ } +/* + Bug #32864 MyODBC /Crystal Reports truncated table names, + lost fields when names > 21chars +*/ +DECLARE_TEST(t_bug32864) +{ + SQLLEN dispsize= 0; + SQLUINTEGER colsize= 0; + + ok_stmt(hstmt, SQLTables(hstmt, "%", SQL_NTS, NULL, 0, NULL, 0, NULL, 0)); + ok_stmt(hstmt, SQLColAttribute(hstmt, 3, SQL_COLUMN_DISPLAY_SIZE, NULL, 0, + NULL, &dispsize)); + + is_num(dispsize, 64); + + ok_stmt(hstmt, SQLDescribeCol(hstmt, 3, NULL, 0, NULL, NULL, + &colsize, NULL, NULL)); + + is_num(colsize, 64); + + return OK; +} + + BEGIN_TESTS ADD_TEST(my_columns_null) ADD_TEST(my_drop_table) @@ -1217,6 +1241,7 @@ ADD_TEST(t_bug29888) ADD_TEST(t_bug14407) ADD_TEST(t_bug19923) + ADD_TEST(t_bug32864) END_TESTS