Fix for bug #9286: SESSION/GLOBAL should be disallowed for user variables

parent 114b421c
......@@ -51,6 +51,7 @@ georg@lmy002.wdf.sap.corp
gerberb@ou800.zenez.com
gluh@gluh.(none)
gluh@gluh.mysql.r18.ru
gluh@mysql.com
gordon@zero.local.lan
greg@gcw.ath.cx
greg@mysql.com
......
......@@ -175,3 +175,7 @@ set @v1=null, @v2=1, @v3=1.1, @v4=now();
select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4)
2 2 2 2
set session @honk=99;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@honk=99' at line 1
set one_shot @honk=99;
ERROR HY000: The SET ONE_SHOT syntax is reserved for purposes internal to the MySQL server
......@@ -111,3 +111,11 @@ select FIELD( @var,'1it','Hit') as my_column;
select @v, coercibility(@v);
set @v1=null, @v2=1, @v3=1.1, @v4=now();
select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
#
# Bug #9286 SESSION/GLOBAL should be disallowed for user variables
#
--error 1064
set session @honk=99;
--error 1105
set one_shot @honk=99;
......@@ -5360,14 +5360,23 @@ opt_option:
| OPTION {};
option_value_list:
option_type option_value
| option_value_list ',' option_type option_value;
option_value_ext
| option_value_list ',' option_value_ext;
option_type:
/* empty */ {}
option_value_ext:
option_type_ext sys_option_value {}
| option_type option_value {}
;
option_type_ext:
option_type {}
| GLOBAL_SYM { Lex->option_type= OPT_GLOBAL; }
| LOCAL_SYM { Lex->option_type= OPT_SESSION; }
| SESSION_SYM { Lex->option_type= OPT_SESSION; }
;
option_type:
/* empty */ {}
| ONE_SHOT_SYM { Lex->option_type= OPT_SESSION; Lex->one_shot_set= 1; }
;
......@@ -5385,23 +5394,13 @@ opt_var_ident_type:
| SESSION_SYM '.' { $$=OPT_SESSION; }
;
option_value:
'@' ident_or_text equal expr
{
Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
}
| internal_variable_name equal set_expr_or_default
sys_option_value:
internal_variable_name equal set_expr_or_default
{
LEX *lex=Lex;
lex->var_list.push_back(new set_var(lex->option_type, $1.var,
&$1.base_name, $3));
}
| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
{
LEX *lex=Lex;
lex->var_list.push_back(new set_var((enum_var_type) $3, $4.var,
&$4.base_name, $6));
}
| TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
{
LEX *lex=Lex;
......@@ -5413,6 +5412,19 @@ option_value:
&tmp,
new Item_int((int32) $4)));
}
;
option_value:
'@' ident_or_text equal expr
{
Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
}
| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
{
LEX *lex=Lex;
lex->var_list.push_back(new set_var((enum_var_type) $3, $4.var,
&$4.base_name, $6));
}
| charset old_or_new_charset_name_or_default
{
THD *thd= YYTHD;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment