Index: driver/utility.c =================================================================== --- driver/utility.c (revision 1113) +++ driver/utility.c (working copy) @@ -422,6 +422,10 @@ UTF8_CHARSET_NUMBER, MYF(0)); + if (!from_cs) + return set_stmt_error(stmt, "HYC00", + "Field character set unsupported in driver.", 0); + if (!result_bytes) result= 0; /* Don't copy anything! */ @@ -671,6 +675,10 @@ UTF8_CHARSET_NUMBER, MYF(0)); + if (!from_cs) + return set_stmt_error(stmt, "HYC00", + "Field character set unsupported in driver.", 0); + if (!result_len) result= NULL; /* Don't copy anything! */ Index: test/my_result.c =================================================================== --- test/my_result.c (revision 1114) +++ test/my_result.c (working copy) @@ -2387,6 +2387,40 @@ } +/* + Bug #36996 - Data provider or other service returned an E_FAIL status + Crashed in copy_wchar_result() due to from_cs as cp1251 is + not compiled into libmysql. +*/ +DECLARE_TEST(t_bug36996) +{ + SQLCHAR res[10]; + SQLWCHAR wres[10]; + + ok_sql(hstmt, "drop table if exists bug36996"); + ok_sql(hstmt, "CREATE TABLE bug36996 ("\ + "the_field varchar(100) character set cp1251)"); + ok_sql(hstmt, "insert into bug36996 values ('1234')"); + + ok_sql(hstmt, "select the_field from bug36996"); + ok_stmt(hstmt, SQLFetch(hstmt)); + + /* check ansi copy */ + expect_stmt(hstmt, SQLGetData(hstmt, 1, SQL_C_CHAR, res, 10, + NULL), SQL_ERROR); + is(check_sqlstate(hstmt, "HYC00") == OK); + + /* check wchar copy */ + expect_stmt(hstmt, SQLGetData(hstmt, 1, SQL_C_WCHAR, wres, 10, + NULL), SQL_ERROR); + is(check_sqlstate(hstmt, "HYC00") == OK); + + ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); + ok_sql(hstmt, "drop table if exists bug36996"); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_resultset) ADD_TEST(t_convert_type) @@ -2423,6 +2457,7 @@ ADD_TEST(t_bug32420) ADD_TEST(t_bug34575) ADD_TEST(t_bug36069) + ADD_TEST(t_bug36996) END_TESTS