Commit 434eeb50 authored by unknown's avatar unknown

Bug#28223: mysqldump --compact --routines restores from @OLD_SQL_MODE w/o ever setting it

mysqldump generated output that set OLD_SQL_MODE twice, to different values
(for triggers), or not at all (for routines) in some cases.
---
Merge blasphemy.mysql.com:/home/tnurnberg/28223/50-28223
into  blasphemy.mysql.com:/home/tnurnberg/28223/51-28223


client/mysqldump.c:
  Bug#28223: mysqldump --compact --routines restores from @OLD_SQL_MODE w/o ever setting it
  
  Only save SQL_MODE in dump_triggers if in --compact mode. Otherwise,
  it's already been saved in write_header(). Likewise for dumpe_routines,
  where it was never saved.
mysql-test/r/mysqldump.result:
  Bug#28223: mysqldump --compact --routines restores from @OLD_SQL_MODE w/o ever setting it
  
  mysqldump output has subtly changed. Adjust test-results. This also shows
  OLD_SQL_MODE is always set exactly once now.
  ---
  manual merge
parent e5353e2f
...@@ -1608,6 +1608,9 @@ static uint dump_routines_for_db(char *db) ...@@ -1608,6 +1608,9 @@ static uint dump_routines_for_db(char *db)
if (lock_tables) if (lock_tables)
mysql_query(mysql, "LOCK TABLES mysql.proc READ"); mysql_query(mysql, "LOCK TABLES mysql.proc READ");
if (opt_compact)
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
fprintf(sql_file, "DELIMITER ;;\n"); fprintf(sql_file, "DELIMITER ;;\n");
/* 0, retrieve and dump functions, 1, procedures */ /* 0, retrieve and dump functions, 1, procedures */
...@@ -2264,8 +2267,11 @@ static void dump_triggers_for_table(char *table, ...@@ -2264,8 +2267,11 @@ static void dump_triggers_for_table(char *table,
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
if (mysql_num_rows(result)) if (mysql_num_rows(result))
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\ {
DELIMITER ;;\n"); if (opt_compact)
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
fprintf(sql_file, "\nDELIMITER ;;\n");
}
while ((row= mysql_fetch_row(result))) while ((row= mysql_fetch_row(result)))
{ {
fprintf(sql_file, fprintf(sql_file,
......
...@@ -2242,7 +2242,6 @@ INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL); ...@@ -2242,7 +2242,6 @@ INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;; DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="" */;; /*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW begin /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW begin
...@@ -2276,7 +2275,6 @@ LOCK TABLES `t2` WRITE; ...@@ -2276,7 +2275,6 @@ LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;; DELIMITER ;;
/*!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 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 */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW begin /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW begin
...@@ -2634,7 +2632,6 @@ INSERT INTO "t1 test" VALUES (1),(2),(3); ...@@ -2634,7 +2632,6 @@ INSERT INTO "t1 test" VALUES (1),(2),(3);
/*!40000 ALTER TABLE "t1 test" ENABLE KEYS */; /*!40000 ALTER TABLE "t1 test" ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;; DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="" */;; /*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `test trig` BEFORE INSERT ON `t1 test` FOR EACH ROW BEGIN
...@@ -2795,7 +2792,6 @@ LOCK TABLES `t1` WRITE; ...@@ -2795,7 +2792,6 @@ LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;; DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="IGNORE_SPACE" */;; /*!50003 SET SESSION SQL_MODE="IGNORE_SPACE" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN
...@@ -3292,12 +3288,16 @@ create database mysqldump_test_db; ...@@ -3292,12 +3288,16 @@ create database mysqldump_test_db;
grant all privileges on mysqldump_test_db.* to user1; grant all privileges on mysqldump_test_db.* to user1;
grant all privileges on mysqldump_test_db.* to user2; grant all privileges on mysqldump_test_db.* to user2;
create procedure mysqldump_test_db.sp1() select 'hello'; create procedure mysqldump_test_db.sp1() select 'hello';
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;; DELIMITER ;;
-- insufficient privileges to SHOW CREATE PROCEDURE `sp1` -- insufficient privileges to SHOW CREATE PROCEDURE `sp1`
-- does user2 have permissions on mysql.proc? -- does user2 have permissions on mysql.proc?
DELIMITER ; DELIMITER ;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;; DELIMITER ;;
/*!50003 SET SESSION SQL_MODE=""*/;; /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`user1`@`%`*/ /*!50003 PROCEDURE `sp1`() /*!50003 CREATE*/ /*!50020 DEFINER=`user1`@`%`*/ /*!50003 PROCEDURE `sp1`()
......
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