MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:April 6 2009 11:00am
Subject:bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2858)
Bug#43385
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bug-43385/ based on revid:alfranio.correia@stripped

 2858 Sergey Glukhov	2009-04-06
      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/update.result
        test result
     @ mysql-test/std_data/bug43385.frm
        test case
     @ mysql-test/t/update.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.

    added:
      mysql-test/std_data/bug43385.frm
    modified:
      mysql-test/r/update.result
      mysql-test/t/update.test
      sql/sql_rename.cc
=== modified file 'mysql-test/r/update.result'
--- a/mysql-test/r/update.result	2008-11-28 16:36:07 +0000
+++ b/mysql-test/r/update.result	2009-04-06 11:00:20 +0000
@@ -503,3 +503,20 @@ ERROR HY000: Recursive stored functions 
 DROP TABLE t1;
 DROP FUNCTION f1;
 End of 5.0 tests
+use `#mysql50#a-b-c`;
+create table t1(f1 int);
+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 create view `a-b-c`.`bug43385`;
+View	Create View	character_set_client	collation_connection
+bug43385	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `bug43385` AS select `a-b-c`.`t1`.`f1` AS `f1`,`tables`.`TABLE_CATALOG` AS `TABLE_CATALOG`,`tables`.`TABLE_SCHEMA` AS `TABLE_SCHEMA`,`tables`.`TABLE_NAME` AS `TABLE_NAME`,`tables`.`TABLE_TYPE` AS `TABLE_TYPE`,`tables`.`ENGINE` AS `ENGINE`,`tables`.`VERSION` AS `VERSION`,`tables`.`ROW_FORMAT` AS `ROW_FORMAT`,`tables`.`TABLE_ROWS` AS `TABLE_ROWS`,`tables`.`AVG_ROW_LENGTH` AS `AVG_ROW_LENGTH`,`tables`.`DATA_LENGTH` AS `DATA_LENGTH`,`tables`.`MAX_DATA_LENGTH` AS `MAX_DATA_LENGTH`,`tables`.`INDEX_LENGTH` AS `INDEX_LENGTH`,`tables`.`DATA_FREE` AS `DATA_FREE`,`tables`.`AUTO_INCREMENT` AS `AUTO_INCREMENT`,`tables`.`CREATE_TIME` AS `CREATE_TIME`,`tables`.`UPDATE_TIME` AS `UPDATE_TIME`,`tables`.`CHECK_TIME` AS `CHECK_TIME`,`tables`.`TABLE_COLLATION` AS `TABLE_COLLATION`,`tables`.`CHECKSUM` AS `CHECKSUM`,`tables`.`CREATE_OPTIONS` AS `CREATE_OPTIONS`,`tables`.`TABLE_COMMENT` AS `TABLE_COMMENT` from!
  (`a-b-c`
+Warnings:
+Note	1600	Creation context of view `a-b-c`.`bug43385' is invalid
+select * from `a-b-c`.`bug43385`;
+f1	TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	VERSION	ROW_FORMAT	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	AUTO_INCREMENT	CREATE_TIME	UPDATE_TIME	CHECK_TIME	TABLE_COLLATION	CHECKSUM	CREATE_OPTIONS	TABLE_COMMENT
+Warnings:
+Note	1600	Creation context of view `a-b-c`.`bug43385' is invalid
+drop database `a-b-c`;
+use test;

=== added file 'mysql-test/std_data/bug43385.frm'
--- a/mysql-test/std_data/bug43385.frm	1970-01-01 00:00:00 +0000
+++ b/mysql-test/std_data/bug43385.frm	2009-04-06 11:00:20 +0000
@@ -0,0 +1,12 @@
+TYPE=VIEW
+query=select `a-b-c`.`t1`.`f1` AS `f1`,`tables`.`TABLE_CATALOG` AS `TABLE_CATALOG`,`tables`.`TABLE_SCHEMA` AS `TABLE_SCHEMA`,`tables`.`TABLE_NAME` AS `TABLE_NAME`,`tables`.`TABLE_TYPE` AS `TABLE_TYPE`,`tables`.`ENGINE` AS `ENGINE`,`tables`.`VERSION` AS `VERSION`,`tables`.`ROW_FORMAT` AS `ROW_FORMAT`,`tables`.`TABLE_ROWS` AS `TABLE_ROWS`,`tables`.`AVG_ROW_LENGTH` AS `AVG_ROW_LENGTH`,`tables`.`DATA_LENGTH` AS `DATA_LENGTH`,`tables`.`MAX_DATA_LENGTH` AS `MAX_DATA_LENGTH`,`tables`.`INDEX_LENGTH` AS `INDEX_LENGTH`,`tables`.`DATA_FREE` AS `DATA_FREE`,`tables`.`AUTO_INCREMENT` AS `AUTO_INCREMENT`,`tables`.`CREATE_TIME` AS `CREATE_TIME`,`tables`.`UPDATE_TIME` AS `UPDATE_TIME`,`tables`.`CHECK_TIME` AS `CHECK_TIME`,`tables`.`TABLE_COLLATION` AS `TABLE_COLLATION`,`tables`.`CHECKSUM` AS `CHECKSUM`,`tables`.`CREATE_OPTIONS` AS `CREATE_OPTIONS`,`tables`.`TABLE_COMMENT` AS `TABLE_COMMENT` from `a-b-c`.`t1` join `information_schema`.`tables`
+md5=5bdf93abd2e87b336550841fd2b18db2
+updatable=0
+algorithm=0
+definer_user=root
+definer_host=localhost
+suid=2
+with_check_option=0
+timestamp=2009-04-06 12:20:19
+create-version=1
+source=select * from `a-b-c`.t1, information_schema.tables

=== modified file 'mysql-test/t/update.test'
--- a/mysql-test/t/update.test	2008-11-28 16:36:07 +0000
+++ b/mysql-test/t/update.test	2009-04-06 11:00:20 +0000
@@ -452,3 +452,19 @@ DROP TABLE t1;
 DROP FUNCTION f1;
 
 --echo End of 5.0 tests
+
+#
+# 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 int);
+--copy_file std_data/bug43385.frm $MYSQLD_DATADIR/a-b-c/bug43385.frm
+
+show databases like '%a-b-c%';
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+show create view `a-b-c`.`bug43385`;
+select * from `a-b-c`.`bug43385`;
+drop database `a-b-c`;
+use test;

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	2008-02-19 12:45:21 +0000
+++ b/sql/sql_rename.cc	2009-04-06 11:00:20 +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-20090406110020-mci9det0w293r0jj.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2858)Bug#43385Sergey Glukhov6 Apr
  • Re: bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2858)Bug#43385Gleb Shchepa9 Apr
    • Re: bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2858)Bug#43385Ramil Kalimullin <ramil@sun.com>10 Apr