List:Commits« Previous MessageNext Message »
From:<gshchepa Date:July 20 2007 10:26pm
Subject:bk commit into 5.0 tree (gshchepa:1.2475) BUG#29788
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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@stripped, 2007-07-21 01:26:32+05:00, gshchepa@stripped +3 -0
  Fixed bug #29788.
  After the dumping of triggers, mysqldump copied 
  the value of the OLD_SQL_MODE variable to the SQL_MODE
  variable. If the --compact option of the mysqldmp was
  unset, the OLD_SQL_MODE variable had the value
  of the uninitialized SQL_MODE variable. So,
  usually the NO_AUTO_VALUE_ON_ZERO option of the
  SQL_MODE variable was discarded.
  
  This fix is for non-"--compact" mode of the mysqldump,
  because mysqldump --compact never set SQL_MODE to the
  value of NO_AUTO_VALUE_ON_ZERO.
  
  The dump_triggers_for_table function has been modified
  to restore previous value of the SQL_MODE variable after
  the dumping of triggers.

  client/mysqldump.c@stripped, 2007-07-21 01:25:53+05:00, gshchepa@stripped +11 -3
    Fixed bug #29788.
    The dump_triggers_for_table function has been modified
    to restore previous value of the SQL_MODE variable after
    the dumping of triggers.

  mysql-test/r/mysqldump.result@stripped, 2007-07-21 01:26:07+05:00, gshchepa@stripped +26 -4
    Updated test case for bug #29788.

  mysql-test/t/mysqldump.test@stripped, 2007-07-21 01:26:06+05:00, gshchepa@stripped +22 -0
    Updated test case for bug #29788.

diff -Nrup a/client/mysqldump.c b/client/mysqldump.c
--- a/client/mysqldump.c	2007-07-18 19:14:19 +05:00
+++ b/client/mysqldump.c	2007-07-21 01:25:53 +05:00
@@ -2167,9 +2167,17 @@ static void dump_triggers_for_table(char
             row[3] /* Statement */);
   }
   if (mysql_num_rows(result))
-    fprintf(sql_file,
-            "DELIMITER ;\n"
-            "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n");
+  {
+    fprintf(sql_file, "DELIMITER ;\n");
+    if (opt_compact)
+      fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n");
+    else
+      fprintf(sql_file,
+              "/*!50003 SET SESSION SQL_MODE='%s%s%s' */;\n",
+              path ? "" : "NO_AUTO_VALUE_ON_ZERO",
+              compatible_mode_normal_str[0] == 0 ? "" : ",",
+              compatible_mode_normal_str);
+  }
   mysql_free_result(result);
   /*
     make sure to set back opt_compatible mode to
diff -Nrup a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
--- a/mysql-test/r/mysqldump.result	2007-07-18 19:14:21 +05:00
+++ b/mysql-test/r/mysqldump.result	2007-07-21 01:26:07 +05:00
@@ -2260,7 +2260,7 @@ end if;
 end */;;
 
 DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET SESSION SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
 DROP TABLE IF EXISTS `t2`;
 CREATE TABLE `t2` (
   `a` int(11) default NULL
@@ -2280,7 +2280,7 @@ end if;
 end */;;
 
 DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET SESSION SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2634,7 +2634,7 @@ DELIMITER ;;
 INSERT INTO `t2 test` SET a2 = NEW.a1; END */;;
 
 DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET SESSION SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
 DROP TABLE IF EXISTS "t2 test";
 CREATE TABLE "t2 test" (
   "a2" int(11) default NULL
@@ -2795,7 +2795,7 @@ SET new.a = 0;
 END */;;
 
 DELIMITER ;
-/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+/*!50003 SET SESSION SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
 /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -3333,6 +3333,28 @@ SELECT * FROM v1;
 1
 1
 DROP VIEW v1;
+#
+# Bug #29788: mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of
+#             the SQL_MODE variable after the dumping of triggers.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TRIGGER t1bd BEFORE DELETE ON t1 FOR EACH ROW BEGIN END;
+CREATE TABLE t2 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
+SET @TMP_SQL_MODE = @@SQL_MODE;
+SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';
+INSERT INTO t2 VALUES (0), (1), (2);
+SET SQL_MODE = @TMP_SQL_MODE;
+SELECT * FROM t2;
+c1
+0
+1
+2
+SELECT * FROM t2;
+c1
+0
+1
+2
+DROP TABLE t1,t2;
 #
 # End of 5.0 tests
 #
diff -Nrup a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
--- a/mysql-test/t/mysqldump.test	2007-07-18 19:14:20 +05:00
+++ b/mysql-test/t/mysqldump.test	2007-07-21 01:26:06 +05:00
@@ -1555,5 +1555,27 @@ SELECT * FROM v1;
 DROP VIEW v1;
 
 --echo #
+--echo # Bug #29788: mysqldump discards the NO_AUTO_VALUE_ON_ZERO value of
+--echo #             the SQL_MODE variable after the dumping of triggers.
+--echo #
+
+CREATE TABLE t1 (c1 INT);
+CREATE TRIGGER t1bd BEFORE DELETE ON t1 FOR EACH ROW BEGIN END;
+
+CREATE TABLE t2 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
+
+SET @TMP_SQL_MODE = @@SQL_MODE;
+SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';
+INSERT INTO t2 VALUES (0), (1), (2);
+SET SQL_MODE = @TMP_SQL_MODE;
+SELECT * FROM t2;
+
+--exec $MYSQL_DUMP --routines test >$MYSQLTEST_VARDIR/tmp/bug29788-1.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug29788-1.sql
+SELECT * FROM t2;
+
+DROP TABLE t1,t2;
+
+--echo #
 --echo # End of 5.0 tests
 --echo #
Thread
bk commit into 5.0 tree (gshchepa:1.2475) BUG#29788gshchepa20 Jul