List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:March 9 2009 9:05pm
Subject:bzr commit into mysql-5.0-bugteam branch (chad:2751) Bug#42635
View as plain text  
#At file:///home/cmiller/work/mysqlbzr/mysql-5.0-bugteam--bug42635/ based on revid:chad@stripped

 2751 Chad MILLER	2009-03-09
      Bug#42635: mysqldump includes views that were excluded using the \
      	--ignore-table option
      
      mysqldump would correctly omit temporary tables for views, but would
      incorrectly still emit all CREATE VIEW statements.
      
      Backport a fix from 5.1, where we capture the names we want to emit
      views for in one pass (the placeholder tables) and in the pass where
      we actually emit the views, we don't emit a view if it wasn't in that
      list.

    modified:
      client/mysqldump.c
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2009-03-09 20:56:46 +0000
+++ b/client/mysqldump.c	2009-03-09 20:58:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -3103,6 +3103,11 @@ static my_bool dump_all_views_in_db(char
   char *table;
   uint numrows;
   char table_buff[NAME_LEN*2+3];
+  char hash_key[2*NAME_LEN+2];  /* "db.tablename" */
+  char *afterdot;
+
+  afterdot= strmov(hash_key, database);
+  *afterdot++= '.';
 
   if (init_dumping(database, init_dumping_views))
     return 1;
@@ -3112,10 +3117,15 @@ static my_bool dump_all_views_in_db(char
   {
     DYNAMIC_STRING query;
     init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024);
-    for (numrows= 0 ; (table= getTableName(1)); numrows++)
+    for (numrows= 0 ; (table= getTableName(1)); )
     {
-      dynstr_append_checked(&query, quote_name(table, table_buff, 1));
-      dynstr_append_checked(&query, " READ /*!32311 LOCAL */,");
+      char *end= strmov(afterdot, table);
+      if (include_table((uchar*) hash_key,end - hash_key))
+      {
+        numrows++;
+        dynstr_append_checked(&query, quote_name(table, table_buff, 1));
+        dynstr_append_checked(&query, " READ /*!32311 LOCAL */,");
+      }
     }
     if (numrows && mysql_real_query(mysql, query.str, query.length-1))
       DB_error(mysql, "when using LOCK TABLES");
@@ -3129,7 +3139,11 @@ static my_bool dump_all_views_in_db(char
            /* We shall continue here, if --force was given */
   }
   while ((table= getTableName(0)))
-     get_view_structure(table, database);
+  {
+    char *end= strmov(afterdot, table);
+    if (include_table((uchar*) hash_key, end - hash_key))
+      get_view_structure(table, database);
+  }
   if (opt_xml)
   {
     fputs("</database>\n", md_result_file);

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2009-02-02 21:20:25 +0000
+++ b/mysql-test/r/mysqldump.result	2009-03-09 20:58:47 +0000
@@ -3574,5 +3574,59 @@ DROP TABLE t1,t2;
 -- Dump completed on DATE
 SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;
 #
+# Bug #42635: mysqldump includes views that were excluded using 
+#   the --ignore-table option
+#
+create database db42635;
+use db42635;
+create table t1 (id int);
+create view db42635.v1 (c) as select * from db42635.t1;
+create view db42635.v2 (c) as select * from db42635.t1;
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+SET @saved_cs_client     = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `t1` (
+  `id` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+SET character_set_client = @saved_cs_client;
+
+LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
+DROP TABLE IF EXISTS `v2`;
+/*!50001 DROP VIEW IF EXISTS `v2`*/;
+/*!50001 CREATE TABLE `v2` (
+  `c` int(11)
+) ENGINE=MyISAM */;
+/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP VIEW IF EXISTS `v2`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `t1`.`id` AS `c` from `t1` */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+use test;
+drop database db42635;
+#
 # End of 5.0 tests
 #

=== modified file 'mysql-test/t/mysqldump.test'
--- a/mysql-test/t/mysqldump.test	2009-02-02 21:20:25 +0000
+++ b/mysql-test/t/mysqldump.test	2009-03-09 20:58:47 +0000
@@ -1649,6 +1649,20 @@ DROP TABLE t1,t2;
 # We reset concurrent_inserts value to whatever it was at the start of the test
 SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;
 
+--echo #
+--echo # Bug #42635: mysqldump includes views that were excluded using 
+--echo #   the --ignore-table option
+--echo #
+
+create database db42635;
+use db42635;
+create table t1 (id int);
+create view db42635.v1 (c) as select * from db42635.t1;
+create view db42635.v2 (c) as select * from db42635.t1;
+--exec $MYSQL_DUMP --skip-comments --ignore-table=db42635.v1 db42635
+use test;
+drop database db42635;
+
 
 --echo #
 --echo # End of 5.0 tests


Attachment: [text/bzr-bundle] bzr/chad@mysql.com-20090309205847-ddjo2ln6n6wi61l1.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (chad:2751) Bug#42635Chad MILLER9 Mar