mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#50755: Crash if stored routine def contains version comments
The problem was that a syntactically invalid trigger could cause the server to crash when trying to list triggers. The crash would happen due to a mishap in the backup/restore procedure that should protect parser items which are not associated with the trigger. The backup/restore is used to isolate the parse tree (and context) of a statement from the load (and parsing) of a trigger. In this case, a error during the parsing of a trigger could cause the improper backup/restore sequence. The solution is to properly restore the original statement context before the parser is exited due to syntax errors in the trigger body. mysql-test/r/trigger.result: Add test case result for Bug#50755 mysql-test/t/trigger.test: Add test case for Bug#50755 sql/sp_head.cc: Merge sp_head::destroy() and sp_head destructor. Retrieve THD from the LEX so that m_thd is not necessary. sql/sql_lex.cc: Explicitly restore the original environment.
This commit is contained in:
@ -2439,4 +2439,35 @@ UPDATE t1 SET id=NULL;
|
||||
DROP TRIGGER t1_bu;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#50755: Crash if stored routine def contains version comments
|
||||
--echo #
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS db1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE db1;
|
||||
USE db1;
|
||||
|
||||
CREATE TABLE t1 (b INT);
|
||||
CREATE TABLE t2 (a INT);
|
||||
|
||||
CREATE TRIGGER trg1 BEFORE INSERT ON t2 FOR EACH ROW INSERT/*!INTO*/t1 VALUES (1);
|
||||
--echo # Used to crash
|
||||
SHOW TRIGGERS IN db1;
|
||||
--error ER_PARSE_ERROR
|
||||
INSERT INTO t2 VALUES (1);
|
||||
SELECT * FROM t1;
|
||||
|
||||
--echo # Work around Bug#45235
|
||||
let $MYSQLD_DATADIR = `select @@datadir`;
|
||||
--remove_file $MYSQLD_DATADIR/db1/t2.TRG
|
||||
--remove_file $MYSQLD_DATADIR/db1/trg1.TRN
|
||||
|
||||
DROP DATABASE db1;
|
||||
USE test;
|
||||
|
||||
--echo End of 5.1 tests.
|
||||
|
Reference in New Issue
Block a user