MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:April 13 2009 1:09pm
Subject:bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2873)
Bug#43385
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:v.narayanan@stripped

 2873 Sergey Glukhov	2009-04-13
      Bug#43385 Cannot ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME when Views exist(addon)
      mysql_rename_view can not rename view if database is not the same.
      The fix is to add new argument 'new_db' to mysql_rename_view() and
      allow rename with different databases
      (only for ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME).
     @ mysql-test/t/upgrade.test
        test fix
     @ sql/parse_file.cc
        mysql_rename_view can not rename view if database is not the same.
        The fix is to add new argument 'new_db' to mysql_rename_view() and
        allow rename with different databases
        (only for ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME).
     @ sql/parse_file.h
        mysql_rename_view can not rename view if database is not the same.
        The fix is to add new argument 'new_db' to mysql_rename_view() and
        allow rename with different databases
        (only for ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME).
     @ sql/sql_rename.cc
        mysql_rename_view can not rename view if database is not the same.
        The fix is to add new argument 'new_db' to mysql_rename_view() and
        allow rename with different databases
        (only for ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME).
     @ sql/sql_view.cc
        mysql_rename_view can not rename view if database is not the same.
        The fix is to add new argument 'new_db' to mysql_rename_view() and
        allow rename with different databases
        (only for ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME).
     @ sql/sql_view.h
        mysql_rename_view can not rename view if database is not the same.
        The fix is to add new argument 'new_db' to mysql_rename_view() and
        allow rename with different databases
        (only for ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME).

    modified:
      mysql-test/t/upgrade.test
      sql/parse_file.cc
      sql/parse_file.h
      sql/sql_rename.cc
      sql/sql_view.cc
      sql/sql_view.h
=== modified file 'mysql-test/t/upgrade.test'
--- a/mysql-test/t/upgrade.test	2009-04-10 09:25:48 +0000
+++ b/mysql-test/t/upgrade.test	2009-04-13 13:09:10 +0000
@@ -116,6 +116,8 @@ 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;
+--disable_ps_protocol
 select * from `a-b-c`.v1;
+--enable_ps_protocol
 drop database `a-b-c`;
 use test;

=== modified file 'sql/parse_file.cc'
--- a/sql/parse_file.cc	2009-02-13 16:41:47 +0000
+++ b/sql/parse_file.cc	2009-04-13 13:09:10 +0000
@@ -302,6 +302,7 @@ err_w_file:
   @thd                     thread handler
   @param schema            name of given schema
   @param old_name          original file name
+  @param new_db            new schema
   @param new_name          new file name
 
   @retval
@@ -311,14 +312,14 @@ err_w_file:
 */
 my_bool rename_in_schema_file(THD *thd,
                               const char *schema, const char *old_name, 
-                              const char *new_name)
+                              const char *new_db, const char *new_name)
 {
   char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN];
 
   build_table_filename(old_path, sizeof(old_path) - 1,
                        schema, old_name, reg_ext, 0);
   build_table_filename(new_path, sizeof(new_path) - 1,
-                       schema, new_name, reg_ext, 0);
+                       new_db, new_name, reg_ext, 0);
 
   if (my_rename(old_path, new_path, MYF(MY_WME)))
     return 1;

=== modified file 'sql/parse_file.h'
--- a/sql/parse_file.h	2009-01-15 18:11:25 +0000
+++ b/sql/parse_file.h	2009-04-13 13:09:10 +0000
@@ -83,7 +83,7 @@ sql_create_definition_file(const LEX_STR
 			   uchar* base, File_option *parameters);
 my_bool rename_in_schema_file(THD *thd,
                               const char *schema, const char *old_name,
-                              const char *new_name);
+                              const char *new_db, const char *new_name);
 
 class File_parser: public Sql_alloc
 {

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	2009-04-10 09:25:48 +0000
+++ b/sql/sql_rename.cc	2009-04-13 13:09:10 +0000
@@ -311,7 +311,7 @@ do_rename(THD *thd, TABLE_LIST *ren_tabl
         my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db, 
                  new_db);
       else
-        rc= mysql_rename_view(thd, new_alias, ren_table);
+        rc= mysql_rename_view(thd, new_db, new_alias, ren_table);
       break;
     default:
       DBUG_ASSERT(0); // should never happen

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	2009-04-08 23:42:51 +0000
+++ b/sql/sql_view.cc	2009-04-13 13:09:10 +0000
@@ -1912,6 +1912,7 @@ int view_checksum(THD *thd, TABLE_LIST *
 
   Parameters:
     thd        thread handler
+    new_db     new name of database
     new_name   new name of view
     view       view
 
@@ -1921,6 +1922,7 @@ int view_checksum(THD *thd, TABLE_LIST *
 */
 bool
 mysql_rename_view(THD *thd,
+                  const char *new_db,
                   const char *new_name,
                   TABLE_LIST *view)
 {
@@ -1959,16 +1961,16 @@ mysql_rename_view(THD *thd,
       goto err;
 
     /* rename view and it's backups */
-    if (rename_in_schema_file(thd, view->db, view->table_name, new_name))
+    if (rename_in_schema_file(thd, view->db, view->table_name, new_db, new_name))
       goto err;
 
     dir.str= dir_buff;
     dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1,
-                                     view->db, "", "", 0);
+                                     new_db, "", "", 0);
 
     pathstr.str= path_buff;
     pathstr.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
-                                      view->db, new_name, reg_ext, 0);
+                                         new_db, new_name, reg_ext, 0);
 
     file.str= pathstr.str + dir.length;
     file.length= pathstr.length - dir.length;
@@ -1977,7 +1979,7 @@ mysql_rename_view(THD *thd,
                                    (uchar*)&view_def, view_parameters))
     {
       /* restore renamed view in case of error */
-      rename_in_schema_file(thd, view->db, new_name, view->table_name);
+      rename_in_schema_file(thd, new_db, new_name, view->db, view->table_name);
       goto err;
     }
   } else

=== modified file 'sql/sql_view.h'
--- a/sql/sql_view.h	2008-02-22 01:21:52 +0000
+++ b/sql/sql_view.h	2009-04-13 13:09:10 +0000
@@ -37,7 +37,8 @@ int view_checksum(THD *thd, TABLE_LIST *
 extern TYPELIB updatable_views_with_limit_typelib;
 
 bool check_duplicate_names(List<Item>& item_list, bool gen_unique_view_names);
-bool mysql_rename_view(THD *thd, const char *new_name, TABLE_LIST *view);
+bool mysql_rename_view(THD *thd, const char *new_db, const char *new_name,
+                       TABLE_LIST *view);
 
 #define VIEW_ANY_ACL (SELECT_ACL | UPDATE_ACL | INSERT_ACL | DELETE_ACL)
 


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20090413130910-9wkbkvzan6zz8mjn.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:2873)Bug#43385Sergey Glukhov13 Apr