Index: driver/utility.c =================================================================== --- driver/utility.c (revision 1123) +++ driver/utility.c (working copy) @@ -371,7 +371,9 @@ */ SQLSMALLINT get_sql_data_type(STMT *stmt, MYSQL_FIELD *field, char *buff) { - my_bool field_is_binary= test(field->charsetnr == 63); + my_bool field_is_binary= test(field->charsetnr == 63) && + (test(field->org_table_length > 0) || + ((stmt->dbc->flag & FLAG_NO_BINARY_RESULT) == 0)); switch (field->type) { case MYSQL_TYPE_BIT: Index: driver/myodbc3.h =================================================================== --- driver/myodbc3.h (revision 1123) +++ 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_types.c =================================================================== --- test/my_types.c (revision 1123) +++ test/my_types.c (working copy) @@ -744,6 +744,45 @@ } +/** + 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; + SQLHENV henv1; + SQLHDBC hdbc1; + SQLHSTMT hstmt1; + + /* First check how the option FLAG_NO_BINARY_RESULT works */ + SET_DSN_OPTION(1 << 28); + + alloc_basic_handles(&henv1, &hdbc1, &hstmt1); + + ok_sql(hstmt1, "SELECT CONCAT('ABCDEFG', 20) concated"); + + ok_stmt(hstmt1, SQLDescribeCol(hstmt1, 1, column_name, sizeof(column_name), + &name_length, &data_type, &column_size, + &decimal_digits, &nullable)); + + is_num(data_type, SQL_VARCHAR); + ok_stmt(hstmt1, SQLFreeStmt(hstmt1, SQL_CLOSE)); + free_basic_handles(&henv1, &hdbc1, &hstmt1); + + /* Check without FLAG_NO_BINARY_RESULT */ + 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_VARBINARY); + return OK; +} + + BEGIN_TESTS ADD_TEST(t_longlong1) ADD_TEST(t_numeric) @@ -760,6 +799,7 @@ ADD_TEST(bit) ADD_TEST(t_bug32171) ADD_TEST(t_bug31220) + ADD_TEST(t_bug29402) END_TESTS Index: setup/MYODBCSetupDataSourceTab3.cpp =================================================================== --- setup/MYODBCSetupDataSourceTab3.cpp (revision 1123) +++ 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 1123) +++ 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 1123) +++ 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 1123) +++ 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 types of the result") ); #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 ); }