summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--mysql-test/r/user_var.result4
-rw-r--r--mysql-test/t/user_var.test8
-rw-r--r--sql/sql_yacc.yy66
4 files changed, 52 insertions, 27 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 90e6c3c100d..9237eea21c4 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -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
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 9edeea404ec..e42849abdf1 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -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
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index b907f21056c..a288b7ef708 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -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;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 9f25e17b6fd..4a23a393fa9 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -5360,17 +5360,26 @@ 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; }
- | ONE_SHOT_SYM { Lex->option_type= OPT_SESSION; Lex->one_shot_set= 1; }
;
+option_type:
+ /* empty */ {}
+ | ONE_SHOT_SYM { Lex->option_type= OPT_SESSION; Lex->one_shot_set= 1; }
+ ;
+
opt_var_type:
/* empty */ { $$=OPT_SESSION; }
| GLOBAL_SYM { $$=OPT_GLOBAL; }
@@ -5385,34 +5394,37 @@ opt_var_ident_type:
| SESSION_SYM '.' { $$=OPT_SESSION; }
;
+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));
+ }
+ | TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
+ {
+ LEX *lex=Lex;
+ LEX_STRING tmp;
+ tmp.str=0;
+ tmp.length=0;
+ lex->var_list.push_back(new set_var(lex->option_type,
+ find_sys_var("tx_isolation"),
+ &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)));
}
- | 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;
- LEX_STRING tmp;
- tmp.str=0;
- tmp.length=0;
- lex->var_list.push_back(new set_var(lex->option_type,
- find_sys_var("tx_isolation"),
- &tmp,
- new Item_int((int32) $4)));
- }
+ {
+ 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;