diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result index 51074650d29..569fdfe4cbf 100644 --- a/mysql-test/main/func_in.result +++ b/mysql-test/main/func_in.result @@ -784,7 +784,7 @@ SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1); # Bug#13012483: EXPLAIN EXTENDED, PREPARED STATEMENT, CRASH IN CHECK_SIMPLE_EQUALITY # CREATE TABLE t1 (a INT); -PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)"; +PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @a:= (1 IN (SELECT 1 FROM t1)) FROM t1)"; EXECUTE s; 1 DROP TABLE t1; @@ -805,15 +805,6 @@ select * from t1 where IF(1,a,a)='2.1'; a b drop table t1; # -# LP bug#992380 Crash when creating PS for a query with -# subquery in WHERE (see also mysql bug#13012483) -# -CREATE TABLE t1 (a INT); -PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)"; -EXECUTE s; -1 -DROP TABLE t1; -# # End of 5.3 tests # create table t1 (a int); diff --git a/mysql-test/main/func_in.test b/mysql-test/main/func_in.test index fb6f2036f20..86a54535a8b 100644 --- a/mysql-test/main/func_in.test +++ b/mysql-test/main/func_in.test @@ -567,7 +567,7 @@ SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1); --echo # CREATE TABLE t1 (a INT); -PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)"; +PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @a:= (1 IN (SELECT 1 FROM t1)) FROM t1)"; EXECUTE s; DROP TABLE t1; @@ -595,15 +595,6 @@ select * from t1 where a='2.1'; select * from t1 where b='2.1'; select * from t1 where IF(1,a,a)='2.1'; drop table t1; ---echo # ---echo # LP bug#992380 Crash when creating PS for a query with ---echo # subquery in WHERE (see also mysql bug#13012483) ---echo # -CREATE TABLE t1 (a INT); -PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)"; -EXECUTE s; - -DROP TABLE t1; --echo # --echo # End of 5.3 tests diff --git a/mysql-test/main/metadata.result b/mysql-test/main/metadata.result index 0704f5b8ae8..1d229643ade 100644 --- a/mysql-test/main/metadata.result +++ b/mysql-test/main/metadata.result @@ -553,19 +553,19 @@ d0l d09 d10 # MDEV-12862 Data type of @a:=1e0 depends on the session character set # SET NAMES utf8; -CREATE TABLE t1 AS SELECT @:=1e0; +CREATE TABLE t1 AS SELECT @a:=1e0; SELECT * FROM t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def test t1 t1 @:=1e0 @:=1e0 5 3 1 N 36865 31 63 -@:=1e0 +def test t1 t1 @a:=1e0 @a:=1e0 5 3 1 N 36865 31 63 +@a:=1e0 1 DROP TABLE t1; SET NAMES latin1; -CREATE TABLE t1 AS SELECT @:=1e0; +CREATE TABLE t1 AS SELECT @a:=1e0; SELECT * FROM t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def test t1 t1 @:=1e0 @:=1e0 5 3 1 N 36865 31 63 -@:=1e0 +def test t1 t1 @a:=1e0 @a:=1e0 5 3 1 N 36865 31 63 +@a:=1e0 1 DROP TABLE t1; # diff --git a/mysql-test/main/metadata.test b/mysql-test/main/metadata.test index 96189a9750a..6a03bc81546 100644 --- a/mysql-test/main/metadata.test +++ b/mysql-test/main/metadata.test @@ -345,11 +345,11 @@ SELECT --echo # --enable_metadata SET NAMES utf8; -CREATE TABLE t1 AS SELECT @:=1e0; +CREATE TABLE t1 AS SELECT @a:=1e0; SELECT * FROM t1; DROP TABLE t1; SET NAMES latin1; -CREATE TABLE t1 AS SELECT @:=1e0; +CREATE TABLE t1 AS SELECT @a:=1e0; SELECT * FROM t1; DROP TABLE t1; --disable_metadata diff --git a/plugin/user_variables/mysql-test/user_variables/basic.result b/plugin/user_variables/mysql-test/user_variables/basic.result index 6d59233c993..3acfb525ba5 100644 --- a/plugin/user_variables/mysql-test/user_variables/basic.result +++ b/plugin/user_variables/mysql-test/user_variables/basic.result @@ -29,13 +29,13 @@ SET @dec_var=CAST(1 AS DECIMAL(20, 10)); SET @time_var=CAST('2016-02-25' AS DATE); SET @' @#^%'='Value of variable with odd name'; SET @''='Value of variable with empty name'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '='Value of variable with empty name'' at line 1 SET @null_var=NULL; SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES; COUNT(*) -10 +9 SELECT * FROM INFORMATION_SCHEMA.USER_VARIABLES ORDER BY VARIABLE_NAME; VARIABLE_NAME VARIABLE_VALUE VARIABLE_TYPE CHARACTER_SET_NAME - Value of variable with empty name VARCHAR latin1 @#^% Value of variable with odd name VARCHAR latin1 dec_var 1.0000000000 DECIMAL latin1 double_var 1 DOUBLE latin1 @@ -47,7 +47,6 @@ uint_var 2 INT UNSIGNED latin1 utf8str_var UTF8 string value VARCHAR utf8mb3 SHOW USER_VARIABLES; Variable_name Value - Value of variable with empty name @#^% Value of variable with odd name dec_var 1.0000000000 double_var 1 diff --git a/plugin/user_variables/mysql-test/user_variables/basic.test b/plugin/user_variables/mysql-test/user_variables/basic.test index 7e67e4fa5af..7432f6537a9 100644 --- a/plugin/user_variables/mysql-test/user_variables/basic.test +++ b/plugin/user_variables/mysql-test/user_variables/basic.test @@ -12,6 +12,7 @@ SET @double_var=CAST(1 AS DOUBLE); SET @dec_var=CAST(1 AS DECIMAL(20, 10)); SET @time_var=CAST('2016-02-25' AS DATE); SET @' @#^%'='Value of variable with odd name'; +--error ER_PARSE_ERROR SET @''='Value of variable with empty name'; SET @null_var=NULL; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9281563969f..deb78f4dfe4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3555,6 +3555,11 @@ simple_target_specification: } | '@' ident_or_text { + if (!$2.length) + { + thd->parse_error(); + YYABORT; + } $$= new (thd->mem_root) Item_func_get_user_var(thd, &$2); if (unlikely($$ == NULL)) MYSQL_YYABORT; @@ -10934,6 +10939,11 @@ variable_aux: ident_or_text SET_VAR expr { Item_func_set_user_var *item; + if (!$1.length) + { + thd->parse_error(); + YYABORT; + } $$= item= new (thd->mem_root) Item_func_set_user_var(thd, &$1, $3); if (unlikely($$ == NULL)) MYSQL_YYABORT; @@ -10943,6 +10953,11 @@ variable_aux: } | ident_or_text { + if (!$1.length) + { + thd->parse_error(); + YYABORT; + } $$= new (thd->mem_root) Item_func_get_user_var(thd, &$1); if (unlikely($$ == NULL)) MYSQL_YYABORT; @@ -12584,6 +12599,12 @@ select_var_ident: select_outvar select_outvar: '@' ident_or_text { + if (!$2.length) + { + thd->parse_error(); + YYABORT; + } + $$ = Lex->result ? new (thd->mem_root) my_var_user(&$2) : NULL; } | ident_or_text @@ -14564,6 +14585,12 @@ field_or_var: simple_ident_nospvar {$$= $1;} | '@' ident_or_text { + if (!$2.length) + { + thd->parse_error(); + YYABORT; + } + $$= new (thd->mem_root) Item_user_var_as_out_param(thd, &$2); if (unlikely($$ == NULL)) MYSQL_YYABORT; @@ -16379,6 +16406,12 @@ option_value_no_option_type: } | '@' ident_or_text equal { + if (!$2.length) + { + thd->parse_error(); + YYABORT; + } + if (sp_create_assignment_lex(thd, $1.str)) MYSQL_YYABORT; }