MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:April 10 2009 9:25am
Subject:bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2868)
Bug#43385
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:davi.arnaut@stripped

 2868 Sergey Glukhov	2009-04-10
      Bug#43385 Cannot ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME when Views exist
      allow 'rename view' for ALTER ...UPGRADE DATA DIRECTORY NAME command.
      it's safe because a view has valid internal db&table names in this case.
     @ mysql-test/r/upgrade.result
        test result
     @ mysql-test/t/upgrade.test
        test case
     @ sql/sql_rename.cc
        allow 'rename view' for ALTER ...UPGRADE DATA DIRECTORY NAME command.
        it's safe because a view has valid internal db&table names in this case.

    modified:
      mysql-test/r/upgrade.result
      mysql-test/t/upgrade.test
      sql/sql_rename.cc
=== modified file 'mysql-test/r/upgrade.result'
--- a/mysql-test/r/upgrade.result	2007-09-10 22:10:37 +0000
+++ b/mysql-test/r/upgrade.result	2009-04-10 09:25:48 +0000
@@ -84,3 +84,23 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MyISAM DEFAULT CHARSET=latin2
 drop database `a-b-c`;
 drop database `tabc`;
+use `#mysql50#a-b-c`;
+create table t1(f1 char(10));
+show databases like '%a-b-c%';
+Database (%a-b-c%)
+#mysql50#a-b-c
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+show databases like '%a-b-c%';
+Database (%a-b-c%)
+a-b-c
+show create view `a-b-c`.v1;
+View	Create View	character_set_client	collation_connection
+v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `a`.`f1` AS `f1` from (`a-b-c`.`t1` `a` join `information_schema`.`tables` `b`) where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`)	utf8	utf8_general_ci
+Warnings:
+Note	1600	Creation context of view `a-b-c`.`v1' is invalid
+select * from `a-b-c`.v1;
+f1
+Warnings:
+Note	1600	Creation context of view `a-b-c`.`v1' is invalid
+drop database `a-b-c`;
+use test;

=== modified file 'mysql-test/t/upgrade.test'
--- a/mysql-test/t/upgrade.test	2009-03-26 14:47:58 +0000
+++ b/mysql-test/t/upgrade.test	2009-04-10 09:25:48 +0000
@@ -89,3 +89,33 @@ show create table `a-b-c`.`t1`;
 drop database `a-b-c`;
 drop database `tabc`;
 
+#
+# Bug#43385 Cannot ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME when Views exist
+#
+let $MYSQLD_DATADIR= `select @@datadir`;
+--mkdir $MYSQLD_DATADIR/a-b-c
+use `#mysql50#a-b-c`;
+create table t1(f1 char(10));
+
+--write_file $MYSQLD_DATADIR/a-b-c/v1.frm
+TYPE=VIEW
+query=select `a`.`f1` AS `f1` from `a-b-c`.`t1` `a` join `information_schema`.`tables` `b` where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`)
+md5=068271f1c657fe115e497856ca0fa493
+updatable=0
+algorithm=0
+definer_user=root
+definer_host=localhost
+suid=2
+with_check_option=0
+timestamp=2009-04-10 11:53:37
+create-version=1
+source=select f1 from `a-b-c`.t1 a, information_schema.tables b\nwhere a.f1 = b.table_name
+EOF
+
+show databases like '%a-b-c%';
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+show databases like '%a-b-c%';
+show create view `a-b-c`.v1;
+select * from `a-b-c`.v1;
+drop database `a-b-c`;
+use test;

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	2009-04-08 23:42:51 +0000
+++ b/sql/sql_rename.cc	2009-04-10 09:25:48 +0000
@@ -301,8 +301,13 @@ do_rename(THD *thd, TABLE_LIST *ren_tabl
       }
       break;
     case FRMTYPE_VIEW:
-      /* change of schema is not allowed */
-      if (strcmp(ren_table->db, new_db))
+      /* 
+         change of schema is not allowed
+         except of ALTER ...UPGRADE DATA DIRECTORY NAME command
+         because a view has valid internal db&table names in this case.
+      */
+      if (thd->lex->sql_command != SQLCOM_ALTER_DB_UPGRADE &&
+          strcmp(ren_table->db, new_db))
         my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db, 
                  new_db);
       else


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20090410092548-k2n3xc2buyu8h671.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2868)Bug#43385Sergey Glukhov10 Apr