MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:May 18 2009 7:55pm
Subject:bzr commit into mysql-5.1-bugteam branch (jimw:2898) Bug#37377
View as plain text  
#At file:///Users/jimw/my/mysql-5.1/ based on revid:jimw@stripped

 2898 Jim Winstead	2009-05-18
      The output of mysqldump --tab for views included a DROP TABLE statement
      without the IF EXISTS qualifier even though no temporary table is created
      as for all-in-one dumps including views. (Bug #37377)
      modified:
        client/mysqldump.c
        mysql-test/r/mysqldump.result
        mysql-test/t/mysqldump.test

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2009-05-12 17:38:14 +0000
+++ b/client/mysqldump.c	2009-05-18 19:52:51 +0000
@@ -4802,7 +4802,8 @@ static my_bool get_view_structure(char *
             result_table);
     check_io(sql_file);
   }
-  fprintf(sql_file, "/*!50001 DROP TABLE %s*/;\n", opt_quoted_table);
+  /* Table might not exist if this view was dumped with --tab. */
+  fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
   if (opt_drop)
   {
     fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2009-05-12 17:45:40 +0000
+++ b/mysql-test/r/mysqldump.result	2009-05-18 19:52:51 +0000
@@ -1991,7 +1991,7 @@ SET character_set_client = utf8;
   `a` varchar(30)
 ) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
-/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -2085,7 +2085,7 @@ SET character_set_client = utf8;
   `a` int(11)
 ) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
-/*!50001 DROP TABLE `v1`*/;
+/*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -2159,7 +2159,7 @@ SET character_set_client = utf8;
   `a` varchar(30)
 ) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
-/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -2293,7 +2293,7 @@ SET character_set_client = utf8;
   `c` varchar(30)
 ) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
-/*!50001 DROP TABLE `v1`*/;
+/*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -2307,7 +2307,7 @@ SET character_set_client = @saved_cs_cli
 /*!50001 SET character_set_client      = @saved_cs_client */;
 /*!50001 SET character_set_results     = @saved_cs_results */;
 /*!50001 SET collation_connection      = @saved_col_connection */;
-/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -2321,7 +2321,7 @@ SET character_set_client = @saved_cs_cli
 /*!50001 SET character_set_client      = @saved_cs_client */;
 /*!50001 SET character_set_results     = @saved_cs_results */;
 /*!50001 SET collation_connection      = @saved_col_connection */;
-/*!50001 DROP TABLE `v3`*/;
+/*!50001 DROP TABLE IF EXISTS `v3`*/;
 /*!50001 DROP VIEW IF EXISTS `v3`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -3054,7 +3054,7 @@ SET character_set_client = utf8;
 SET character_set_client = @saved_cs_client;
 
 USE `test`;
-/*!50001 DROP TABLE `v0`*/;
+/*!50001 DROP TABLE IF EXISTS `v0`*/;
 /*!50001 DROP VIEW IF EXISTS `v0`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -3068,7 +3068,7 @@ USE `test`;
 /*!50001 SET character_set_client      = @saved_cs_client */;
 /*!50001 SET character_set_results     = @saved_cs_results */;
 /*!50001 SET collation_connection      = @saved_col_connection */;
-/*!50001 DROP TABLE `v1`*/;
+/*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -3082,7 +3082,7 @@ USE `test`;
 /*!50001 SET character_set_client      = @saved_cs_client */;
 /*!50001 SET character_set_results     = @saved_cs_results */;
 /*!50001 SET collation_connection      = @saved_col_connection */;
-/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -3320,7 +3320,7 @@ insert into t values(5, 51);
 create view v1 as select qty, price, qty*price as value from t;
 create view v2 as select qty from v1;
 mysqldump {
-/*!50001 DROP TABLE `v1`*/;
+/*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
 /*!50001 SET @saved_col_connection     = @@collation_connection */;
@@ -3335,7 +3335,7 @@ mysqldump {
 /*!50001 SET collation_connection      = @saved_col_connection */;
 
 } mysqldump {
-/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
 /*!50001 SET @saved_col_connection     = @@collation_connection */;
@@ -3434,7 +3434,7 @@ SET character_set_client = utf8;
 SET character_set_client = @saved_cs_client;
 
 USE `mysqldump_test_db`;
-/*!50001 DROP TABLE `v1`*/;
+/*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -3496,7 +3496,7 @@ SET character_set_client = @saved_cs_cli
 USE `mysqldump_tables`;
 
 USE `mysqldump_views`;
-/*!50001 DROP TABLE `nasishnasifu`*/;
+/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
 /*!50001 SET @saved_col_connection     = @@collation_connection */;
@@ -3885,7 +3885,7 @@ SET character_set_client = utf8;
   `c` int(11)
 ) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
-/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -4304,7 +4304,7 @@ SET character_set_client = utf8;
 SET character_set_client = @saved_cs_client;
 
 USE `mysqldump_test_db`;
-/*!50001 DROP TABLE `v1`*/;
+/*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
 /*!50001 SET @saved_cs_client          = @@character_set_client */;
 /*!50001 SET @saved_cs_results         = @@character_set_results */;
@@ -4430,6 +4430,15 @@ DROP DATABASE mysqldump_test_db;
 
 # -- End of test case for Bug#32538.
 
+#
+# Bug#37377 Incorrect DROP TABLE statement in dump of a VIEW using --tab
+#
+create table t1 (a int);
+create view v1 as select a from t1;
+drop view v1;
+drop table t1;
+drop view v1;
+drop table t1;
 SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;
 #
 # End of 5.1 tests

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2009-05-15 19:24:45 +0000
+++ b/mysql-test/t/mysqldump.test	2009-05-18 19:52:51 +0000
@@ -1948,6 +1948,29 @@ DROP DATABASE mysqldump_test_db;
 --echo # -- End of test case for Bug#32538.
 --echo
 
+--echo #
+--echo # Bug#37377 Incorrect DROP TABLE statement in dump of a VIEW using --tab
+--echo #
+
+create table t1 (a int);
+create view v1 as select a from t1;
+
+--exec $MYSQL_DUMP --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test t1 v1
+
+drop view v1;
+drop table t1;
+
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/v1.sql
+
+drop view v1;
+drop table t1;
+
+--remove_file $MYSQLTEST_VARDIR/tmp/t1.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt
+--remove_file $MYSQLTEST_VARDIR/tmp/v1.sql
+
+
 # We reset concurrent_inserts value to whatever it was at the start of the test
 # This line must be executed _after_ all test cases.
 SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;

Thread
bzr commit into mysql-5.1-bugteam branch (jimw:2898) Bug#37377Jim Winstead18 May