Skip to content

Commit 8f7edb7

Browse files
committed
MDEV-26637: (variables) ASAN: main.metadata and user_variables.basic MTR failures after MDEV-26572
Prohibit user variables without name
1 parent af8b2c6 commit 8f7edb7

File tree

7 files changed

+46
-31
lines changed

7 files changed

+46
-31
lines changed

mysql-test/main/func_in.result

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
784784
# Bug#13012483: EXPLAIN EXTENDED, PREPARED STATEMENT, CRASH IN CHECK_SIMPLE_EQUALITY
785785
#
786786
CREATE TABLE t1 (a INT);
787-
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
787+
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @a:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
788788
EXECUTE s;
789789
1
790790
DROP TABLE t1;
@@ -805,15 +805,6 @@ select * from t1 where IF(1,a,a)='2.1';
805805
a b
806806
drop table t1;
807807
#
808-
# LP bug#992380 Crash when creating PS for a query with
809-
# subquery in WHERE (see also mysql bug#13012483)
810-
#
811-
CREATE TABLE t1 (a INT);
812-
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
813-
EXECUTE s;
814-
1
815-
DROP TABLE t1;
816-
#
817808
# End of 5.3 tests
818809
#
819810
create table t1 (a int);

mysql-test/main/func_in.test

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
567567
--echo #
568568

569569
CREATE TABLE t1 (a INT);
570-
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
570+
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @a:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
571571
EXECUTE s;
572572

573573
DROP TABLE t1;
@@ -595,15 +595,6 @@ select * from t1 where a='2.1';
595595
select * from t1 where b='2.1';
596596
select * from t1 where IF(1,a,a)='2.1';
597597
drop table t1;
598-
--echo #
599-
--echo # LP bug#992380 Crash when creating PS for a query with
600-
--echo # subquery in WHERE (see also mysql bug#13012483)
601-
--echo #
602-
CREATE TABLE t1 (a INT);
603-
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
604-
EXECUTE s;
605-
606-
DROP TABLE t1;
607598

608599
--echo #
609600
--echo # End of 5.3 tests

mysql-test/main/metadata.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,19 +553,19 @@ d0l d09 d10
553553
# MDEV-12862 Data type of @a:=1e0 depends on the session character set
554554
#
555555
SET NAMES utf8;
556-
CREATE TABLE t1 AS SELECT @:=1e0;
556+
CREATE TABLE t1 AS SELECT @a:=1e0;
557557
SELECT * FROM t1;
558558
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
559-
def test t1 t1 @:=1e0 @:=1e0 5 3 1 N 36865 31 63
560-
@:=1e0
559+
def test t1 t1 @a:=1e0 @a:=1e0 5 3 1 N 36865 31 63
560+
@a:=1e0
561561
1
562562
DROP TABLE t1;
563563
SET NAMES latin1;
564-
CREATE TABLE t1 AS SELECT @:=1e0;
564+
CREATE TABLE t1 AS SELECT @a:=1e0;
565565
SELECT * FROM t1;
566566
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
567-
def test t1 t1 @:=1e0 @:=1e0 5 3 1 N 36865 31 63
568-
@:=1e0
567+
def test t1 t1 @a:=1e0 @a:=1e0 5 3 1 N 36865 31 63
568+
@a:=1e0
569569
1
570570
DROP TABLE t1;
571571
#

mysql-test/main/metadata.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,11 @@ SELECT
345345
--echo #
346346
--enable_metadata
347347
SET NAMES utf8;
348-
CREATE TABLE t1 AS SELECT @:=1e0;
348+
CREATE TABLE t1 AS SELECT @a:=1e0;
349349
SELECT * FROM t1;
350350
DROP TABLE t1;
351351
SET NAMES latin1;
352-
CREATE TABLE t1 AS SELECT @:=1e0;
352+
CREATE TABLE t1 AS SELECT @a:=1e0;
353353
SELECT * FROM t1;
354354
DROP TABLE t1;
355355
--disable_metadata

plugin/user_variables/mysql-test/user_variables/basic.result

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ SET @dec_var=CAST(1 AS DECIMAL(20, 10));
2929
SET @time_var=CAST('2016-02-25' AS DATE);
3030
SET @' @#^%'='Value of variable with odd name';
3131
SET @''='Value of variable with empty name';
32+
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
3233
SET @null_var=NULL;
3334
SELECT COUNT(*) FROM INFORMATION_SCHEMA.USER_VARIABLES;
3435
COUNT(*)
35-
10
36+
9
3637
SELECT * FROM INFORMATION_SCHEMA.USER_VARIABLES ORDER BY VARIABLE_NAME;
3738
VARIABLE_NAME VARIABLE_VALUE VARIABLE_TYPE CHARACTER_SET_NAME
38-
Value of variable with empty name VARCHAR latin1
3939
@#^% Value of variable with odd name VARCHAR latin1
4040
dec_var 1.0000000000 DECIMAL latin1
4141
double_var 1 DOUBLE latin1
@@ -47,7 +47,6 @@ uint_var 2 INT UNSIGNED latin1
4747
utf8str_var UTF8 string value VARCHAR utf8mb3
4848
SHOW USER_VARIABLES;
4949
Variable_name Value
50-
Value of variable with empty name
5150
@#^% Value of variable with odd name
5251
dec_var 1.0000000000
5352
double_var 1

plugin/user_variables/mysql-test/user_variables/basic.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SET @double_var=CAST(1 AS DOUBLE);
1212
SET @dec_var=CAST(1 AS DECIMAL(20, 10));
1313
SET @time_var=CAST('2016-02-25' AS DATE);
1414
SET @' @#^%'='Value of variable with odd name';
15+
--error ER_PARSE_ERROR
1516
SET @''='Value of variable with empty name';
1617
SET @null_var=NULL;
1718

sql/sql_yacc.yy

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,6 +3555,11 @@ simple_target_specification:
35553555
}
35563556
| '@' ident_or_text
35573557
{
3558+
if (!$2.length)
3559+
{
3560+
thd->parse_error();
3561+
YYABORT;
3562+
}
35583563
$$= new (thd->mem_root) Item_func_get_user_var(thd, &$2);
35593564
if (unlikely($$ == NULL))
35603565
MYSQL_YYABORT;
@@ -10934,6 +10939,11 @@ variable_aux:
1093410939
ident_or_text SET_VAR expr
1093510940
{
1093610941
Item_func_set_user_var *item;
10942+
if (!$1.length)
10943+
{
10944+
thd->parse_error();
10945+
YYABORT;
10946+
}
1093710947
$$= item= new (thd->mem_root) Item_func_set_user_var(thd, &$1, $3);
1093810948
if (unlikely($$ == NULL))
1093910949
MYSQL_YYABORT;
@@ -10943,6 +10953,11 @@ variable_aux:
1094310953
}
1094410954
| ident_or_text
1094510955
{
10956+
if (!$1.length)
10957+
{
10958+
thd->parse_error();
10959+
YYABORT;
10960+
}
1094610961
$$= new (thd->mem_root) Item_func_get_user_var(thd, &$1);
1094710962
if (unlikely($$ == NULL))
1094810963
MYSQL_YYABORT;
@@ -12584,6 +12599,12 @@ select_var_ident: select_outvar
1258412599
select_outvar:
1258512600
'@' ident_or_text
1258612601
{
12602+
if (!$2.length)
12603+
{
12604+
thd->parse_error();
12605+
YYABORT;
12606+
}
12607+
1258712608
$$ = Lex->result ? new (thd->mem_root) my_var_user(&$2) : NULL;
1258812609
}
1258912610
| ident_or_text
@@ -14564,6 +14585,12 @@ field_or_var:
1456414585
simple_ident_nospvar {$$= $1;}
1456514586
| '@' ident_or_text
1456614587
{
14588+
if (!$2.length)
14589+
{
14590+
thd->parse_error();
14591+
YYABORT;
14592+
}
14593+
1456714594
$$= new (thd->mem_root) Item_user_var_as_out_param(thd, &$2);
1456814595
if (unlikely($$ == NULL))
1456914596
MYSQL_YYABORT;
@@ -16379,6 +16406,12 @@ option_value_no_option_type:
1637916406
}
1638016407
| '@' ident_or_text equal
1638116408
{
16409+
if (!$2.length)
16410+
{
16411+
thd->parse_error();
16412+
YYABORT;
16413+
}
16414+
1638216415
if (sp_create_assignment_lex(thd, $1.str))
1638316416
MYSQL_YYABORT;
1638416417
}

0 commit comments

Comments
 (0)