Commit 2caa5608 authored by unknown's avatar unknown

Bug#16878 dump of trigger

 - Pass "in_comment" variable on to new lex in sp_head::reset_lex
 - Add testcases for dumping and reloading trigger without BEGIN/END


mysql-test/r/mysqldump.result:
  Update test result
mysql-test/t/mysqldump.test:
  Add test for dumping trigger without begin/end, and test that the output from mysqldump can be reloaded.
sql/sp_head.cc:
  If already in a comment before parsing a substatement, set in_comment in the new lex as well.
  This will handle cases where the comment starts before the substatement, which is common in 
  output from mysqldump to mask away syntax not supported by earlier versions of MySQL.
  Ex:
  /*!50003 CREATE TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW
  set new.created=now() */;
  ^=== sp_head::reset_lex is called when already in comment
parent f220f892
......@@ -2611,3 +2611,25 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
create table t1 (a int, created datetime);
create table t2 (b int, created datetime);
create trigger tr1 before insert on t1 for each row set
new.created=now();
create trigger tr2 after insert on t1
for each row
begin
insert into t2 set b=new.a and created=new.created;
end|
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
tr1 INSERT t1 set
new.created=now() BEFORE # root@localhost
tr2 INSERT t1 begin
insert into t2 set b=new.a and created=new.created;
end AFTER # root@localhost
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
......@@ -1036,3 +1036,33 @@ insert into t1 values ('','');
drop table t1;
# End of 4.1 tests
#
# Bug #16878 dump of trigger
#
create table t1 (a int, created datetime);
create table t2 (b int, created datetime);
create trigger tr1 before insert on t1 for each row set
new.created=now();
delimiter |;
create trigger tr2 after insert on t1
for each row
begin
insert into t2 set b=new.a and created=new.created;
end|
delimiter ;|
# dump table and trigger
--exec $MYSQL_DUMP test > var/tmp/bug16878.sql
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
# reload dump
--exec $MYSQL test < var/tmp/bug16878.sql
--replace_column 6 #
show triggers;
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
......@@ -1584,6 +1584,8 @@ sp_head::reset_lex(THD *thd)
sublex->trg_table_fields.empty();
sublex->sp_lex_in_use= FALSE;
sublex->in_comment= oldlex->in_comment;
/* Reset type info. */
sublex->charset= NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment