Browse Source

MDEV-15620 Crash when using "SET @@NEW.a=expr" inside a trigger

A simple patch fixing the problem in 5.5.
Note, a full patch was previously fixed to 10.3.
pull/1146/head
Alexander Barkov 8 years ago
parent
commit
e8c2366bf8
  1. 7
      mysql-test/r/parser.result
  2. 9
      mysql-test/t/parser.test
  3. 5
      sql/sql_yacc.yy

7
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;

9
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;

5
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)
{

Loading…
Cancel
Save