MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Ignacio Galarza Date:July 17 2006 10:07pm
Subject:bk commit into 5.0 tree (iggy:1.2227) BUG#20221
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of iggy. When iggy 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, 2006-07-17 18:07:08-04:00, iggy@stripped +3 -0
  Bug# 20221- Dumping of multiple databases containing view(s) yields maleformed dumps.

  client/mysqldump.c@stripped, 2006-07-17 18:07:05-04:00, iggy@stripped +14 -3
    When dumping more than one database, make sure that the proper database is selected before restoring that database's views.
    Replaced hard-coded database name length with appropiate token.

  mysql-test/r/mysqldump.result@stripped, 2006-07-17 18:07:05-04:00, iggy@stripped +39 -0
    Added new result and corrected results for existing test cases.

  mysql-test/t/mysqldump.test@stripped, 2006-07-17 18:07:05-04:00, iggy@stripped +38 -0
    Added new case for dumping and restoring multiple databases each containing a view.

# 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:	iggy
# Host:	rolltop.ignatz42.dyndns.org
# Root:	/mnt/storeage/mysql-5.0-release

--- 1.233/client/mysqldump.c	2006-07-17 18:07:14 -04:00
+++ 1.234/client/mysqldump.c	2006-07-17 18:07:14 -04:00
@@ -2637,7 +2637,7 @@
       /*
         length of table name * 2 (if name contains quotes), 2 quotes and 0
       */
-      char quoted_database_buf[64*2+3];
+      char quoted_database_buf[NAME_LEN*2+3];
       char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
       if (opt_comments)
       {
@@ -2786,7 +2786,18 @@
     DB_error(sock, "when selecting the database");
     return 1;
   }
-
+  if (opt_databases || opt_alldbs)
+  {
+    char quoted_database_buf[NAME_LEN*2+3];
+    char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
+    if (opt_comments)
+    {
+      fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
+      check_io(md_result_file);
+    }
+    fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
+    check_io(md_result_file);
+  }
   if (opt_xml)
     print_xml_tag1(md_result_file, "", "database name=", database, "\n");
   if (lock_tables)
@@ -3239,7 +3250,7 @@
   MYSQL_RES  *res = NULL;
   MYSQL_ROW  row;
   /* SHOW KEYS FROM + table name * 2 (escaped) + 2 quotes + \0 */
-  char show_keys_buff[15 + 64 * 2 + 3];
+  char show_keys_buff[15 + NAME_LEN * 2 + 3];
   uint result_length = 0;
   char *result = 0;
 

--- 1.101/mysql-test/r/mysqldump.result	2006-07-17 18:07:14 -04:00
+++ 1.102/mysql-test/r/mysqldump.result	2006-07-17 18:07:14 -04:00
@@ -2503,6 +2503,8 @@
   `b` varchar(32),
   `c` varchar(32)
 ) */;
+
+USE `test`;
 /*!50001 DROP TABLE IF EXISTS `v0`*/;
 /*!50001 DROP VIEW IF EXISTS `v0`*/;
 /*!50001 CREATE ALGORITHM=UNDEFINED */
@@ -2826,6 +2828,8 @@
 /*!50001 CREATE TABLE `v1` (
   `id` int(11)
 ) */;
+
+USE `mysqldump_test_db`;
 /*!50001 DROP TABLE IF EXISTS `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
 /*!50001 CREATE ALGORITHM=UNDEFINED */
@@ -2867,6 +2871,10 @@
 /*!50001 CREATE TABLE `nasishnasifu` (
   `id` bigint(20) unsigned
 ) */;
+
+USE `mysqldump_tables`;
+
+USE `mysqldump_views`;
 /*!50001 CREATE ALGORITHM=UNDEFINED */
 /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
 /*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
@@ -2874,3 +2882,34 @@
 drop database mysqldump_views;
 drop table mysqldump_tables.basetable;
 drop database mysqldump_tables;
+create database mysqldump_dba;
+use mysqldump_dba;
+create table t1 (f1 int, f2 int);
+insert into t1 values (1,1);
+create view v1 as select f1, f2 from t1;
+create database mysqldump_dbb;
+use mysqldump_dbb;
+create table t1 (f1 int, f2 int);
+insert into t1 values (2,2);
+create view v1 as select f1, f2 from t1;
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+select * from mysqldump_dba.v1;
+f1	f2
+1	1
+select * from mysqldump_dbb.v1;
+f1	f2
+2	2
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+use mysqldump_dbb;
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;

--- 1.94/mysql-test/t/mysqldump.test	2006-07-17 18:07:14 -04:00
+++ 1.95/mysql-test/t/mysqldump.test	2006-07-17 18:07:14 -04:00
@@ -1230,3 +1230,41 @@
 drop database mysqldump_views;
 drop table mysqldump_tables.basetable;
 drop database mysqldump_tables;
+
+# Bug20221 Dumping of multiple databases containing view(s) yields maleformed dumps
+
+create database mysqldump_dba;
+use mysqldump_dba;
+create table t1 (f1 int, f2 int);
+insert into t1 values (1,1);
+create view v1 as select f1, f2 from t1;
+
+create database mysqldump_dbb;
+use mysqldump_dbb;
+create table t1 (f1 int, f2 int);
+insert into t1 values (2,2);
+create view v1 as select f1, f2 from t1;
+
+--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_dba mysqldump_dbb > $MYSQLTEST_VARDIR/tmp/bug20221_backup;
+
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20221_backup;
+
+select * from mysqldump_dba.v1;
+select * from mysqldump_dbb.v1;
+
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+use mysqldump_dbb;
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
Thread
bk commit into 5.0 tree (iggy:1.2227) BUG#20221Ignacio Galarza18 Jul