diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index ab550026dbc..aaf977efe50 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -233,6 +233,10 @@ set character_set_client=UNKNOWN_CHARACTER_SET; ERROR 42000: Unknown character set: 'UNKNOWN_CHARACTER_SET' set collation_connection=UNKNOWN_COLLATION; ERROR HY000: Unknown collation: 'UNKNOWN_COLLATION' +set character_set_client=NULL; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'NULL' +set collation_connection=NULL; +ERROR 42000: Variable 'collation_connection' can't be set to the value of 'NULL' set global autocommit=1; ERROR HY000: Variable 'autocommit' is a SESSION variable and can't be used with SET GLOBAL select @@global.timestamp; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 26eacb86164..843a417bb25 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -137,6 +137,10 @@ set GLOBAL storage_engine=DEFAULT; set character_set_client=UNKNOWN_CHARACTER_SET; --error 1273 set collation_connection=UNKNOWN_COLLATION; +--error 1231 +set character_set_client=NULL; +--error 1231 +set collation_connection=NULL; --error 1228 set global autocommit=1; --error 1238 diff --git a/sql/set_var.cc b/sql/set_var.cc index d59a01f01cb..5d2a6c1d39e 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1678,7 +1678,10 @@ bool sys_var_collation::check(THD *thd, set_var *var) String str(buff,sizeof(buff), system_charset_info), *res; if (!(res=var->value->val_str(&str))) - res= &my_empty_string; + { + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + return 1; + } if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0)))) { @@ -1700,7 +1703,7 @@ bool sys_var_character_set::check(THD *thd, set_var *var) { if (!nullable) { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "NULL"); + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); return 1; } tmp= NULL;