From: Date: July 29 2005 10:15pm Subject: bk commit into 5.0 tree (bell:1.1892) BUG#5891 List-Archive: http://lists.mysql.com/internals/27729 X-Bug: 5891 Message-Id: <20050729201513.93DAE455F12@sanja.is.com.ua> Below is the list of changes that have just been committed into a local 5.0 repository of bell. When bell does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1892 05/07/29 23:15:05 bell@stripped +7 -0 Added sql_mode saving to mysql_dump (BUG#5891, part 2) sql/set_var.cc 1.127 05/07/29 23:15:01 bell@stripped +7 -4 fixed comment mysql-test/t/sp.test 1.135 05/07/29 23:15:01 bell@stripped +1 -1 now sql_mode preserved in SP mysql-test/t/mysqldump.test 1.53 05/07/29 23:15:01 bell@stripped +4 -0 changed test, to test sql_mode mysql-test/r/sp.result 1.140 05/07/29 23:15:01 bell@stripped +4 -4 now sql_mode preserved in SP mysql-test/r/mysqldump.result 1.59 05/07/29 23:15:01 bell@stripped +58 -28 changed test, to test sql_mode client/mysqldump.c 1.192 05/07/29 23:15:01 bell@stripped +21 -14 fixed short simbol for trigger fixed lines break for more compiler compatibility added sql_mode output added comments made protection of trigger and view restoring commands from execution by old versions of mysql client/client_priv.h 1.38 05/07/29 23:15:01 bell@stripped +2 -1 add OPT_ for --trigger parameter # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: bell # Host: sanja.is.com.ua # Root: /home/bell/mysql/bk/work-trigger-5.0 --- 1.191/client/mysqldump.c 2005-07-22 05:11:20 +03:00 +++ 1.192/client/mysqldump.c 2005-07-29 23:15:01 +03:00 @@ -372,7 +372,7 @@ (gptr*) &path, (gptr*) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"triggers", '/0', "Dump triggers for each dumped table", + {"triggers", OPT_TRIGGER, "Dump triggers for each dumped table", (gptr*) &opt_dump_triggers, (gptr*) &opt_dump_triggers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE @@ -1296,10 +1296,11 @@ row= mysql_fetch_row(tableRes); if (opt_drop) - fprintf(sql_file, "DROP VIEW IF EXISTS %s;\n",opt_quoted_table); + fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", + opt_quoted_table); /* Print CREATE statement but remove TEMPORARY */ - fprintf(sql_file, "CREATE %s;\n", row[1]+17); + fprintf(sql_file, "/*!50001 CREATE %s*/;\n", row[1]+17); check_io(sql_file); mysql_free_result(tableRes); @@ -1335,19 +1336,23 @@ DBUG_RETURN(0); } if (mysql_num_rows(tableRes)) - fprintf(sql_file, "\nDELIMITER //;\n"); + fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\ +DELIMITER //;\n"); while ((row=mysql_fetch_row(tableRes))) { - fprintf(sql_file, "CREATE TRIGGER %s %s %s ON %s\n" - "FOR EACH ROW%s//\n\n", - quote_name(row[0], name_buff, 0), - row[4], - row[1], + fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/ //\n\ +/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s*/ //\n\n", + row[6], /* sql_mode */ + quote_name(row[0], name_buff, 0), /* Trigger */ + row[4], /* Timing */ + row[1], /* Event */ result_table, - row[3]); + row[3] /* Statement */); } if (mysql_num_rows(tableRes)) - fprintf(sql_file, "DELIMITER ;//"); + fprintf(sql_file, + "DELIMITER ;//\n\ +/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;"); mysql_free_result(tableRes); } } @@ -2957,13 +2962,15 @@ } if (opt_drop) { - fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", opt_quoted_table); - fprintf(sql_file, "DROP VIEW IF EXISTS %s;\n", opt_quoted_table); + fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", + opt_quoted_table); + fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", + opt_quoted_table); check_io(sql_file); } row= mysql_fetch_row(table_res); - fprintf(sql_file, "%s;\n", row[1]); + fprintf(sql_file, "/*!50001 %s*/;\n", row[1]); check_io(sql_file); mysql_free_result(table_res); --- 1.37/client/client_priv.h 2005-05-26 13:58:50 +03:00 +++ 1.38/client/client_priv.h 2005-07-29 23:15:01 +03:00 @@ -49,5 +49,6 @@ #ifdef HAVE_NDBCLUSTER_DB OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, #endif - OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE + OPT_IGNORE_TABLE, OPT_INSERT_IGNORE, OPT_SHOW_WARNINGS, OPT_DROP_DATABASE, + OPT_TRIGGER }; --- 1.126/sql/set_var.cc 2005-07-28 22:39:07 +03:00 +++ 1.127/sql/set_var.cc 2005-07-29 23:15:01 +03:00 @@ -3199,10 +3199,13 @@ /* Make string representation of mode - SINOPSYS - thd thread handler - val sql_mode value - len pointer on length of string + SINOPSIS + thd in thread handler + val in sql_mode value + len out pointer on length of string + + RETURN + pointer to string with sql_mode representation */ byte *sys_var_thd_sql_mode::symbolic_mode_representation(THD *thd, ulong val, --- 1.139/mysql-test/r/sp.result 2005-07-22 09:11:17 +03:00 +++ 1.140/mysql-test/r/sp.result 2005-07-29 23:15:01 +03:00 @@ -2658,20 +2658,20 @@ drop procedure avg| drop procedure if exists bug6129| set @old_mode= @@sql_mode; -set @@sql_mode= ""; +set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO"; create procedure bug6129() select @@sql_mode| call bug6129()| @@sql_mode - +ERROR_FOR_DIVISION_BY_ZERO set @@sql_mode= "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"| call bug6129()| @@sql_mode -NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO +ERROR_FOR_DIVISION_BY_ZERO set @@sql_mode= "NO_ZERO_IN_DATE"| call bug6129()| @@sql_mode -NO_ZERO_IN_DATE +ERROR_FOR_DIVISION_BY_ZERO set @@sql_mode=@old_mode; drop procedure bug6129| drop procedure if exists bug9856| --- 1.134/mysql-test/t/sp.test 2005-07-22 09:11:17 +03:00 +++ 1.135/mysql-test/t/sp.test 2005-07-29 23:15:01 +03:00 @@ -3378,7 +3378,7 @@ drop procedure if exists bug6129| --enable_warnings set @old_mode= @@sql_mode; -set @@sql_mode= ""; +set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO"; create procedure bug6129() select @@sql_mode| call bug6129()| --- 1.58/mysql-test/r/mysqldump.result 2005-07-22 05:11:20 +03:00 +++ 1.59/mysql-test/r/mysqldump.result 2005-07-29 23:15:01 +03:00 @@ -379,13 +379,13 @@ UNLOCK TABLES; /*!40000 ALTER TABLE `t1` ENABLE KEYS */; DROP TABLE IF EXISTS `v1`; -DROP VIEW IF EXISTS `v1`; -CREATE TABLE `v1` ( +/*!50001 DROP VIEW IF EXISTS `v1`*/; +/*!50001 CREATE TABLE `v1` ( `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `v1`; -DROP VIEW IF EXISTS `v1`; -CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1`; +) ENGINE=MyISAM DEFAULT CHARSET=latin1*/; +/*!50001 DROP TABLE IF EXISTS `v1`*/; +/*!50001 DROP VIEW IF EXISTS `v1`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1`*/; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1462,13 +1462,13 @@ UNLOCK TABLES; /*!40000 ALTER TABLE `t2` ENABLE KEYS */; DROP TABLE IF EXISTS `v2`; -DROP VIEW IF EXISTS `v2`; -CREATE TABLE `v2` ( +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE TABLE `v2` ( `a` varchar(30) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -DROP TABLE IF EXISTS `v2`; -DROP VIEW IF EXISTS `v2`; -CREATE ALGORITHM=UNDEFINED VIEW `db1`.`v2` AS select `db1`.`t2`.`a` AS `a` from `db1`.`t2` where (`db1`.`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION; +) ENGINE=MyISAM DEFAULT CHARSET=latin1*/; +/*!50001 DROP TABLE IF EXISTS `v2`*/; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED VIEW `db1`.`v2` AS select `db1`.`t2`.`a` AS `a` from `db1`.`t2` where (`db1`.`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1685,6 +1685,7 @@ create trigger trg2 before update on t1 for each row begin if old.a % 2 = 0 then set new.b := 12; end if; end| +set sql_mode="traditional"| create trigger trg3 after update on t1 for each row begin if new.a = -1 then @@ -1697,24 +1698,25 @@ set @fired:= "No"; end if; end| +set sql_mode=default| show triggers like "t1"; -Trigger Event Table Statement Timing Created +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 0000-00-00 00:00:00 +end BEFORE 0000-00-00 00:00:00 trg2 UPDATE t1 begin 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 begin if new.a = -1 then set @fired:= "Yes"; 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); update t1 set a = 4 where a=3; @@ -1736,30 +1738,32 @@ `b` bigint(20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER //; -CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` -FOR EACH ROW +/*!50003 SET SESSION SQL_MODE=""*/ // +/*!50003 CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW begin if new.a > 10 then set new.a := 10; set new.a := 11; end if; -end// +end*/ // -CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` -FOR EACH ROW begin +/*!50003 SET SESSION SQL_MODE=""*/ // +/*!50003 CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin if old.a % 2 = 0 then set new.b := 12; end if; -end// +end*/ // -CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` -FOR EACH ROW +/*!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"*/ // +/*!50003 CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW begin if new.a = -1 then set @fired:= "Yes"; end if; -end// +end*/ // DELIMITER ;// +/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; LOCK TABLES `t1` WRITE; @@ -1771,16 +1775,18 @@ `a` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; DELIMITER //; -CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` -FOR EACH ROW +/*!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"*/ // +/*!50003 CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW begin if new.a > 10 then set @fired:= "No"; end if; -end// +end*/ // DELIMITER ;// +/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/; /*!40000 ALTER TABLE `t2` DISABLE KEYS */; LOCK TABLES `t2` WRITE; @@ -1844,4 +1850,28 @@ Tables_in_test t1 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 DROP TABLE t1, t2; --- 1.52/mysql-test/t/mysqldump.test 2005-07-22 05:11:21 +03:00 +++ 1.53/mysql-test/t/mysqldump.test 2005-07-29 23:15:01 +03:00 @@ -727,6 +727,7 @@ create trigger trg2 before update on t1 for each row begin if old.a % 2 = 0 then set new.b := 12; end if; end| +set sql_mode="traditional"| create trigger trg3 after update on t1 for each row begin if new.a = -1 then @@ -739,6 +740,7 @@ set @fired:= "No"; end if; end| +set sql_mode=default| delimiter ;| --replace_column 6 '0000-00-00 00:00:00' show triggers like "t1"; @@ -754,4 +756,6 @@ --exec $MYSQL test < var/tmp/mysqldump.sql # Check that tables have been reloaded show tables; +--replace_column 6 # +show triggers; DROP TABLE t1, t2;