diff options
-rw-r--r-- | mysql-test/r/parser.result | 7 | ||||
-rw-r--r-- | mysql-test/t/parser.test | 9 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 5 |
3 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 9a14c0e324b..70dc7a4c1cf 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -672,3 +672,10 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\'; 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 '\' at line 1 DROP TABLE t1; +# +# MDEV-15620 Crash when using "SET @@NEW.a=expr" inside a trigger +# +CREATE TABLE t1 (a INT); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @@NEW.a=0; +ERROR HY000: Unknown system variable 'NEW' +DROP TABLE t1; diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 1e3458eafdf..06ec3164ad1 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -780,3 +780,12 @@ CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\; --error ER_PARSE_ERROR PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\'; DROP TABLE t1; + +--echo # +--echo # MDEV-15620 Crash when using "SET @@NEW.a=expr" inside a trigger +--echo # + +CREATE TABLE t1 (a INT); +--error ER_UNKNOWN_SYSTEM_VARIABLE +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @@NEW.a=0; +DROP TABLE t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e1c6b5b6276..bf47153c0c1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13567,6 +13567,11 @@ option_value: | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default { struct sys_var_with_base tmp= $4; + if (tmp.var == trg_new_row_fake_var) + { + my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), "NEW"); + MYSQL_YYABORT; + } /* Lookup if necessary: must be a system variable. */ if (tmp.var == NULL) { |