CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1`;
/*!50001 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1`*/;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
...
@@ -1595,13 +1595,13 @@ INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
...
@@ -1595,13 +1595,13 @@ INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
UNLOCK TABLES;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `v2`;
DROP TABLE IF EXISTS `v2`;
DROP VIEW IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
CREATE TABLE `v2` (
/*!50001 CREATE TABLE `v2` (
`a` varchar(30) default NULL
`a` varchar(30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
DROP VIEW IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
CREATE ALGORITHM=UNDEFINED VIEW `mysqldump_test_db`.`v2` AS select `mysqldump_test_db`.`t2`.`a` AS `a` from `mysqldump_test_db`.`t2` where (`mysqldump_test_db`.`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION;
/*!50001 CREATE ALGORITHM=UNDEFINED VIEW `mysqldump_test_db`.`v2` AS select `mysqldump_test_db`.`t2`.`a` AS `a` from `mysqldump_test_db`.`t2` where (`mysqldump_test_db`.`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
...
@@ -1685,6 +1685,7 @@ end|
...
@@ -1685,6 +1685,7 @@ end|
create trigger trg2 before update on t1 for each row begin
create trigger trg2 before update on t1 for each row begin
if old.a % 2 = 0 then set new.b := 12; end if;
if old.a % 2 = 0 then set new.b := 12; end if;
end|
end|
set sql_mode="traditional"|
create trigger trg3 after update on t1 for each row
create trigger trg3 after update on t1 for each row
begin
begin
if new.a = -1 then
if new.a = -1 then
...
@@ -1697,24 +1698,25 @@ if new.a > 10 then
...
@@ -1697,24 +1698,25 @@ if new.a > 10 then
set @fired:= "No";
set @fired:= "No";
end if;
end if;
end|
end|
set sql_mode=default|
show triggers like "t1";
show triggers like "t1";
Trigger Event Table Statement Timing Created
Trigger Event Table Statement Timing Created sql_mode
trg1 INSERT t1
trg1 INSERT t1
begin
begin
if new.a > 10 then
if new.a > 10 then
set new.a := 10;
set new.a := 10;
set new.a := 11;
set new.a := 11;
end if;
end if;
end BEFORE 0000-00-00 00:00:00
end BEFORE 0000-00-00 00:00:00
trg2 UPDATE t1 begin
trg2 UPDATE t1 begin
if old.a % 2 = 0 then set new.b := 12; end if;
if old.a % 2 = 0 then set new.b := 12; end if;
end BEFORE 0000-00-00 00:00:00
end BEFORE 0000-00-00 00:00:00
trg3 UPDATE t1
trg3 UPDATE t1
begin
begin
if new.a = -1 then
if new.a = -1 then
set @fired:= "Yes";
set @fired:= "Yes";
end if;
end if;
end AFTER 0000-00-00 00:00:00
end AFTER 0000-00-00 00:00:00 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
update t1 set a = 4 where a=3;
update t1 set a = 4 where a=3;
...
@@ -1736,30 +1738,32 @@ CREATE TABLE `t1` (
...
@@ -1736,30 +1738,32 @@ CREATE TABLE `t1` (
`b` bigint(20) default NULL
`b` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //;
DELIMITER //;
CREATE TRIGGER `trg1` BEFORE INSERT ON `t1`
/*!50003 SET SESSION SQL_MODE=""*/ //
FOR EACH ROW
/*!50003 CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW
begin
begin
if new.a > 10 then
if new.a > 10 then
set new.a := 10;
set new.a := 10;
set new.a := 11;
set new.a := 11;
end if;
end if;
end//
end*/ //
CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1`
/*!50003 SET SESSION SQL_MODE=""*/ //
FOR EACH ROW begin
/*!50003 CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin
if old.a % 2 = 0 then set new.b := 12; end if;
if old.a % 2 = 0 then set new.b := 12; end if;
end//
end*/ //
CREATE TRIGGER `trg3` AFTER UPDATE ON `t1`
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER"*/ //
FOR EACH ROW
/*!50003 CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW
begin
begin
if new.a = -1 then
if new.a = -1 then
set @fired:= "Yes";
set @fired:= "Yes";
end if;
end if;
end//
end*/ //
DELIMITER ;//
DELIMITER ;//
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
LOCK TABLES `t1` WRITE;
...
@@ -1771,16 +1775,18 @@ CREATE TABLE `t2` (
...
@@ -1771,16 +1775,18 @@ CREATE TABLE `t2` (
`a` int(11) default NULL
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //;
DELIMITER //;
CREATE TRIGGER `trg4` BEFORE INSERT ON `t2`
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER"*/ //
FOR EACH ROW
/*!50003 CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW
begin
begin
if new.a > 10 then
if new.a > 10 then
set @fired:= "No";
set @fired:= "No";
end if;
end if;
end//
end*/ //
DELIMITER ;//
DELIMITER ;//
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
LOCK TABLES `t2` WRITE;
...
@@ -1844,4 +1850,28 @@ show tables;
...
@@ -1844,4 +1850,28 @@ show tables;
Tables_in_test
Tables_in_test
t1
t1
t2
t2
show triggers;
Trigger Event Table Statement Timing Created sql_mode
trg1 INSERT t1
begin
if new.a > 10 then
set new.a := 10;
set new.a := 11;
end if;
end BEFORE #
trg2 UPDATE t1 begin
if old.a % 2 = 0 then set new.b := 12; end if;
end BEFORE #
trg3 UPDATE t1
begin
if new.a = -1 then
set @fired:= "Yes";
end if;
end AFTER # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
trg4 INSERT t2
begin
if new.a > 10 then
set @fired:= "No";
end if;
end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER