List:Commits« Previous MessageNext Message »
From:Ingo Struewing Date:January 4 2010 12:03pm
Subject:bzr commit into mysql-backup-backport branch (ingo.struewing:3021)
Bug#38045 WL#5101
View as plain text  
#At file:///home2/mydev/bzrroot/mysql-5.6-backup-backport-ms09-2/ based on revid:ingo.struewing@sun.com-20091231190918-udxpg1ylezde0ayo

 3021 Ingo Struewing	2010-01-04
      WL#5101 - MySQL Backup back port - MS09
      Merged revid:ingo.struewing@strippedvbu0
        Bug#38045 - Backup, MyISAM and file system encoding
        
        Table names with non-ASCII characters could not be backed up.
        
        The MyISAM native backup driver used the original, non-translated table name.
        
        Fixed by using the translated name.
      
      original changeset: 2599.1.63
     @ mysql-test/r/backup_myisam2.result
        WL#5101 - MySQL Backup back port - MS09
            Bug#38045 - Backup, MyISAM and file system encoding
            Added test result.
     @ mysql-test/t/backup_myisam2.test
        WL#5101 - MySQL Backup back port - MS09
            Bug#38045 - Backup, MyISAM and file system encoding
            Added test.
     @ storage/myisam/myisam_backup_engine.cc
        WL#5101 - MySQL Backup back port - MS09
            Using translated table names.
            Simplified string copy.
            Added error detection for string copy.

    modified:
      mysql-test/r/backup_myisam2.result
      mysql-test/t/backup_myisam2.test
      storage/myisam/myisam_backup_engine.cc
=== modified file 'mysql-test/r/backup_myisam2.result'
--- a/mysql-test/r/backup_myisam2.result	2009-12-31 19:09:18 +0000
+++ b/mysql-test/r/backup_myisam2.result	2010-01-04 12:03:52 +0000
@@ -69,7 +69,18 @@ mysqltest.t1	1728069308
 
 connection default: cleanup
 SET DEBUG_SYNC= 'RESET';
+
+#
+# Bug#38045 - Backup, MyISAM and file system encoding
+#
+CREATE TABLE `�ߣ�(id SERIAL) ENGINE=MyISAM;
+BACKUP DATABASE mysqltest TO 'test.ba';
+backup_id
+#
+DROP TABLE `�ߣ�
+# final cleanup
 drop database mysqltest;
+USE test;
 
 # Verify that the MyISAM Key Cache is still enabled.
 # See Bug#44068 (RESTORE can disable the MyISAM Key Cache).

=== modified file 'mysql-test/t/backup_myisam2.test'
--- a/mysql-test/t/backup_myisam2.test	2009-12-31 19:09:18 +0000
+++ b/mysql-test/t/backup_myisam2.test	2010-01-04 12:03:52 +0000
@@ -84,10 +84,24 @@ SET DEBUG_SYNC= 'now SIGNAL bup_finish';
 --echo
 --echo connection default: cleanup
 connection default;
+--remove_file $MYSQLD_BACKUPDIR/test.ba
 SET DEBUG_SYNC= 'RESET';
-drop database mysqltest;
+
+
+--echo
+--echo #
+--echo # Bug#38045 - Backup, MyISAM and file system encoding
+--echo #
+CREATE TABLE `�ߣ�(id SERIAL) ENGINE=MyISAM;
+--replace_column 1 #
+BACKUP DATABASE mysqltest TO 'test.ba';
+DROP TABLE `�ߣ�
 --remove_file $MYSQLD_BACKUPDIR/test.ba
 
+--echo # final cleanup
+drop database mysqltest;
+USE test;
+
 --echo
 --echo # Verify that the MyISAM Key Cache is still enabled.
 --echo # See Bug#44068 (RESTORE can disable the MyISAM Key Cache).

=== modified file 'storage/myisam/myisam_backup_engine.cc'
--- a/storage/myisam/myisam_backup_engine.cc	2009-12-30 20:58:50 +0000
+++ b/storage/myisam/myisam_backup_engine.cc	2010-01-04 12:03:52 +0000
@@ -132,8 +132,9 @@ protected:
 
 Myisam_table_ref::Myisam_table_ref(const Table_ref &tbl)
 {
-  const char *db_arg= tbl.db().name().ptr();
-  const char *name_arg= tbl.name().ptr();
+  int error= 0;
+  char path[FN_REFLEN];
+
   /**
     We keep local copies of the db and name. This is because during restore,
     the Table_ref is apparently modified before the Table_restore is done
@@ -144,22 +145,28 @@ Myisam_table_ref::Myisam_table_ref(const
     and this will save memory.
     As Rafal is changing relevant code now, it may go away.
   */
-  db.append(db_arg);
-  name.append(name_arg);
+  if (db.append(tbl.db().name()))
+    error= 1;
+  if (name.append(tbl.name()))
+    error= 1;
+  /*
+    Note: when we repair the table, we use open_temporary_table() which
+    requires db and table name separated. The internal_name is the
+    translated table name with ASCII characters only.
+  */
+  (void) tbl.internal_name(path, sizeof(path));
+  if (file_name.append(path))
+    error= 1;
   /*
-    Note: this way below will break with non-ASCII characters;
-    what driver should be passed is what engine used to create the table, ie
-    output of build_table_filename().
-    Just replace "building" with "bûilding" in backup.test to see issues.
-    This is remembered in WL#4060.
-
-    But note, when we repair the table, we use open_temporary_table() which
-    requires db and table name separated.
-  */
-  file_name.append("./");
-  file_name.append(db_arg);
-  file_name.append("/");
-  file_name.append(name_arg);
+    If one of the string allocations failed, clear all. This should be
+    noticed later, when we try to use the information.
+  */
+  if (error)
+  {
+    db.set("", 0, system_charset_info);
+    name.set("", 0, system_charset_info);
+    file_name.set("", 0, system_charset_info);
+  }
 }
 
 
@@ -539,15 +546,20 @@ result_t Backup::begin(const size_t)
   /* Build the hash of tables for the MyISAM layer (mi_log.c etc) */
   for (uint n=0 ; n < m_tables.count() ; n++ )
   {
+    char path[FN_REFLEN];
     char unique_file_name[FN_REFLEN], *str;
     size_t str_len;
     ::LEX_STRING *hash_key;
 
-    my_realpath(unique_file_name,
-                fn_format(unique_file_name,m_tables[n].name().ptr(),
-                          m_tables[n].db().name().ptr(),
-                          MI_NAME_IEXT,
-                          MY_UNPACK_FILENAME), MYF(MY_WME));
+    /*
+      The internal_name is the translated table name with ASCII
+      characters only.
+    */
+    (void) m_tables[n].internal_name(path, sizeof(path));
+    if (my_realpath(unique_file_name,
+                    fn_format(unique_file_name, path, "", MI_NAME_IEXT,
+                              MY_UNPACK_FILENAME), MYF(MY_WME)))
+        SET_STATE_TO_ERROR_AND_DBUG_RETURN;
     str_len= strlen(unique_file_name);
     my_multi_malloc(MYF(MY_WME),
                     &hash_key, sizeof(*hash_key),

Attachment: [text/bzr-bundle] bzr/ingo.struewing@sun.com-20100104120352-1p5t7vteghx69ch3.bundle
Thread
bzr commit into mysql-backup-backport branch (ingo.struewing:3021)Bug#38045 WL#5101Ingo Struewing4 Jan