Index: driver/utility.c =================================================================== --- driver/utility.c (revision 1113) +++ driver/utility.c (working copy) @@ -372,6 +372,8 @@ SQLSMALLINT get_sql_data_type(STMT *stmt, MYSQL_FIELD *field, char *buff) { my_bool field_is_binary= test(field->charsetnr == 63); + my_bool allow_binary= test(field->org_table_length > 0) || + ((stmt->dbc->flag & FLAG_NO_BINARY_RESULT) == 0); switch (field->type) { case MYSQL_TYPE_BIT: @@ -498,9 +500,10 @@ case MYSQL_TYPE_STRING: if (buff) - (void)strmov(buff, field_is_binary ? "binary" : "char"); + (void)strmov(buff, (field_is_binary && allow_binary) ? + "binary" : "char"); - return field_is_binary ? SQL_BINARY : SQL_CHAR; + return (field_is_binary && allow_binary) ? SQL_BINARY : SQL_CHAR; /* MYSQL_TYPE_VARCHAR is never actually sent, this just silences @@ -509,33 +512,42 @@ case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VAR_STRING: if (buff) - (void)strmov(buff, field_is_binary ? "varbinary" : "varchar"); + (void)strmov(buff, (field_is_binary && allow_binary) ? + "varbinary" : "varchar"); - return field_is_binary ? SQL_VARBINARY : SQL_VARCHAR; + return (field_is_binary && allow_binary) ? SQL_VARBINARY : SQL_VARCHAR; case MYSQL_TYPE_TINY_BLOB: if (buff) - (void)strmov(buff, field_is_binary ? "tinyblob" : "tinytext"); + (void)strmov(buff, (field_is_binary && allow_binary) ? + "tinyblob" : "tinytext"); - return field_is_binary ? SQL_LONGVARBINARY : SQL_LONGVARCHAR; + return (field_is_binary && allow_binary) ? + SQL_LONGVARBINARY : SQL_LONGVARCHAR; case MYSQL_TYPE_BLOB: if (buff) - (void)strmov(buff, field_is_binary ? "blob" : "text"); + (void)strmov(buff, (field_is_binary && allow_binary) ? + "blob" : "text"); - return field_is_binary ? SQL_LONGVARBINARY : SQL_LONGVARCHAR; + return (field_is_binary && allow_binary) ? + SQL_LONGVARBINARY : SQL_LONGVARCHAR; case MYSQL_TYPE_MEDIUM_BLOB: if (buff) - (void)strmov(buff, field_is_binary ? "mediumblob" : "mediumtext"); + (void)strmov(buff, (field_is_binary && allow_binary) ? + "mediumblob" : "mediumtext"); - return field_is_binary ? SQL_LONGVARBINARY : SQL_LONGVARCHAR; + return (field_is_binary && allow_binary) ? + SQL_LONGVARBINARY : SQL_LONGVARCHAR; case MYSQL_TYPE_LONG_BLOB: if (buff) - (void)strmov(buff, field_is_binary ? "longblob" : "longtext"); + (void)strmov(buff, (field_is_binary && allow_binary) ? + "longblob" : "longtext"); - return field_is_binary ? SQL_LONGVARBINARY : SQL_LONGVARCHAR; + return (field_is_binary && allow_binary) ? + SQL_LONGVARBINARY : SQL_LONGVARCHAR; case MYSQL_TYPE_ENUM: if (buff) Index: driver/myodbc3.h =================================================================== --- driver/myodbc3.h (revision 1113) +++ driver/myodbc3.h (working copy) @@ -161,6 +161,7 @@ #define FLAG_MIN_DATE_TO_ZERO (1 << 25) /* Convert ODBC min date to 0000-00-00 on query */ #define FLAG_MULTI_STATEMENTS (1 << 26) /* Allow multiple statements in a query */ #define FLAG_COLUMN_SIZE_S32 (1 << 27) /* Limit column size to a signed 32-bit value (automatically set for ADO) */ +#define FLAG_NO_BINARY_RESULT (1 << 28) /* Disables charset 63 for columns with empty org_table */ /* We don't make any assumption about what the default may be. */ #ifndef DEFAULT_TXN_ISOLATION Index: test/my_catalog.c =================================================================== --- test/my_catalog.c (revision 1113) +++ test/my_catalog.c (working copy) @@ -1309,6 +1309,26 @@ } +/** + Bug #29402: field type charset 63 problem +*/ +DECLARE_TEST(t_bug29402) +{ + SQLSMALLINT name_length, data_type, decimal_digits, nullable; + SQLCHAR column_name[SQL_MAX_COLUMN_NAME_LEN]; + SQLULEN column_size; + + ok_sql(hstmt, "SELECT CONCAT('ABCDEFG', 20) concated"); + + ok_stmt(hstmt, SQLDescribeCol(hstmt, 1, column_name, sizeof(column_name), + &name_length, &data_type, &column_size, + &decimal_digits, &nullable)); + + is_num(data_type, SQL_VARCHAR); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_columns_null) ADD_TEST(my_drop_table) @@ -1336,6 +1356,7 @@ ADD_TEST(t_bug33298) ADD_TEST(t_bug12805) ADD_TEST(t_bug30770) + ADD_TEST(t_bug29402) END_TESTS Index: setup/MYODBCSetupDataSourceTab3.cpp =================================================================== --- setup/MYODBCSetupDataSourceTab3.cpp (revision 1113) +++ setup/MYODBCSetupDataSourceTab3.cpp (working copy) @@ -98,6 +98,8 @@ nFlags |= 1 << 26; if ( ptab3c->pcheckboxCapColumnSize->isChecked() ) nFlags |= 1 << 27; + if ( ptab3a->pcheckboxDisableBinaryResult->isChecked() ) + nFlags |= 1 << 28; return nFlags; } Index: setup/MYODBCSetupDataSourceTab3a.h =================================================================== --- setup/MYODBCSetupDataSourceTab3a.h (revision 1113) +++ setup/MYODBCSetupDataSourceTab3a.h (working copy) @@ -49,6 +49,7 @@ MYODBCSetupCheckBox *pcheckboxSafe; MYODBCSetupCheckBox *pcheckboxEnableReconnect; MYODBCSetupCheckBox *pcheckboxAutoIncrementIsNull; + MYODBCSetupCheckBox *pcheckboxDisableBinaryResult; }; #endif Index: setup/MYODBCSetupDataSourceDialog.cpp =================================================================== --- setup/MYODBCSetupDataSourceDialog.cpp (revision 1113) +++ setup/MYODBCSetupDataSourceDialog.cpp (working copy) @@ -431,6 +431,7 @@ ptab3->ptab3a->pcheckboxAutoIncrementIsNull->setChecked( nOptions & (1 << 23) ? TRUE : FALSE ); ptab3->ptab3c->pcheckboxMultiStatements->setChecked( nOptions & (1 << 26) ? TRUE : FALSE ); ptab3->ptab3c->pcheckboxCapColumnSize->setChecked( nOptions & (1 << 27) ? TRUE : FALSE ); + ptab3->ptab3a->pcheckboxDisableBinaryResult->setChecked( nOptions & (1 << 28) ? TRUE : FALSE ); } connect( ppushbuttonTest, SIGNAL(clicked()), SLOT(slotTest()) ); @@ -467,6 +468,7 @@ connect( ptab3->ptab3a->pcheckboxSafe, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); connect( ptab3->ptab3a->pcheckboxEnableReconnect, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); connect( ptab3->ptab3a->pcheckboxAutoIncrementIsNull, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); + connect( ptab3->ptab3a->pcheckboxDisableBinaryResult, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); connect( ptab3->ptab3b->pcheckboxDontPromptOnConnect, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); connect( ptab3->ptab3b->pcheckboxEnableDynamicCursor, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); connect( ptab3->ptab3b->pcheckboxIgnorePoundInTable, SIGNAL(signalAssistText(const QString&)), ptextbrowserAssist, SLOT(setHtml(const QString&)) ); Index: setup/MYODBCSetupDataSourceTab3a.cpp =================================================================== --- setup/MYODBCSetupDataSourceTab3a.cpp (revision 1113) +++ setup/MYODBCSetupDataSourceTab3a.cpp (working copy) @@ -30,6 +30,7 @@ QString stringSafe( tr("Add some extra safety checks (should not be needed but...).") ); QString stringEnableReconnect( tr("Enables automatic reconnect. Attention: it is strongly not recommended to set this flag for transactional operations!") ); QString stringAutoIncrementIsNull( tr("Turns on/off the handling of searching for the last inserted row with WHERE auto_increment_column IS NULL") ); + QString stringDisableBinaryResult( tr("Forces non-binary result types") ); #if QT_VERSION >= 0x040000 QVBoxLayout * playoutFields = new QVBoxLayout; setLayout( playoutFields ); @@ -103,6 +104,15 @@ QToolTip::add( pcheckboxAutoIncrementIsNull, stringAutoIncrementIsNull ); #endif + pcheckboxDisableBinaryResult = new MYODBCSetupCheckBox( tr("Force non-binary result types"), this ); + pcheckboxDisableBinaryResult->setAssistText( stringDisableBinaryResult ); + playoutFields->addWidget( pcheckboxDisableBinaryResult ); +#if QT_VERSION >= 0x040000 + pcheckboxDisableBinaryResult->setToolTip( stringDisableBinaryResult ); +#else + QToolTip::add( pcheckboxDisableBinaryResult, stringDisableBinaryResult ); +#endif + playoutFields->addStretch( 10 ); }