diff --git a/mysql-test/r/set_statement.result b/mysql-test/r/set_statement.result index 51687caeb21..bf367b505f3 100644 --- a/mysql-test/r/set_statement.result +++ b/mysql-test/r/set_statement.result @@ -1138,3 +1138,11 @@ password(a) deallocate prepare stmt1; drop table t1; set @@old_passwords=@save_old_passwords; +# +#MDEV-6951:Erroneous SET STATEMENT produces two identical errors +# +set statement non_existing=1 for select 1; +ERROR HY000: Unknown system variable 'non_existing' +show errors; +Level Code Message +Error 1193 Unknown system variable 'non_existing' diff --git a/mysql-test/t/set_statement.test b/mysql-test/t/set_statement.test index 6421317935a..75d70b11858 100644 --- a/mysql-test/t/set_statement.test +++ b/mysql-test/t/set_statement.test @@ -1068,3 +1068,11 @@ execute stmt1; deallocate prepare stmt1; drop table t1; set @@old_passwords=@save_old_passwords; + +--echo # +--echo #MDEV-6951:Erroneous SET STATEMENT produces two identical errors +--echo # + +--error ER_UNKNOWN_SYSTEM_VARIABLE +set statement non_existing=1 for select 1; +show errors; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5021e475903..492e774509e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -367,9 +367,7 @@ find_sys_var_null_base(THD *thd, struct sys_var_with_base *tmp) { tmp->var= find_sys_var(thd, tmp->base_name.str, tmp->base_name.length); - if (tmp->var == NULL) - my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), tmp->base_name.str); - else + if (tmp->var != NULL) tmp->base_name= null_lex_str; return thd->is_error();