List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:March 6 2009 9:45am
Subject:bzr commit into mysql-6.0-backup branch (jorgen.loland:2790) Bug#42402
View as plain text  
#At file:///localhome/jl208045/mysql/mysql-6.0-backup-42402/

 2790 Jorgen Loland	2009-03-06
      Bug#42402 - Restore crashes server if tablespace does not exist
            
      Before, RESTORE would crash if the backup image contained tables originally stored
      in a tablespace that no longer exists at RESTORE time.
            
      With this patch, the tablespace is recreated like it was at BACKUP time if it does
      not exist when RESTORE is executed.
modified:
  mysql-test/suite/backup/r/backup_tablespace.result
  mysql-test/suite/backup/t/backup_tablespace.test
  sql/backup/kernel.cc
  sql/si_objects.cc

per-file messages:
  mysql-test/suite/backup/r/backup_tablespace.result
    Add test for RESTORE after dropping a dependant tablespace
  mysql-test/suite/backup/t/backup_tablespace.test
    Add test for RESTORE after dropping a dependant tablespace
  sql/backup/kernel.cc
    Fix multiline if-block without {...}
  sql/si_objects.cc
    Make find_tablespace return NULL if the tablespace does not exist on the server.
=== modified file 'mysql-test/suite/backup/r/backup_tablespace.result'
--- a/mysql-test/suite/backup/r/backup_tablespace.result	2009-02-27 11:16:44 +0000
+++ b/mysql-test/suite/backup/r/backup_tablespace.result	2009-03-06 09:45:28 +0000
@@ -208,8 +208,37 @@ INSERT INTO t VALUES (1);
 BACKUP DATABASE backup_ts TO 'ts_drop.bak';
 backup_id
 #
+
+# Show tablespace info
+SELECT t1.tablespace_name, t1.engine, t1.tablespace_type, t2.file_name, t2.file_type FROM INFORMATION_SCHEMA.TABLESPACES AS t1, INFORMATION_SCHEMA.FILES AS t2 WHERE t1.tablespace_name = t2.tablespace_name AND t1.tablespace_name = 'TB';;
+tablespace_name	TB
+engine	Falcon
+tablespace_type	USER DEFINED
+file_name	tblspace.fts
+file_type	USER DATAFILE
+
 DROP DATABASE backup_ts;
 DROP TABLESPACE tb ENGINE=FALCON;
 
-BUG#42402 - Crashes.
+# Restore and verify database content
+
+RESTORE FROM 'ts_drop.bak';
+backup_id
+#
+SHOW TABLES IN backup_ts;
+Tables_in_backup_ts
+t
+SELECT * FROM backup_ts.t;
+s1
+1
+
+# Show tablespace info
+SELECT t1.tablespace_name, t1.engine, t1.tablespace_type, t2.file_name, t2.file_type FROM INFORMATION_SCHEMA.TABLESPACES AS t1, INFORMATION_SCHEMA.FILES AS t2 WHERE t1.tablespace_name = t2.tablespace_name AND t1.tablespace_name = 'TB';;
+tablespace_name	TB
+engine	Falcon
+tablespace_type	USER DEFINED
+file_name	tblspace.fts
+file_type	USER DATAFILE
 
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;

=== modified file 'mysql-test/suite/backup/t/backup_tablespace.test'
--- a/mysql-test/suite/backup/t/backup_tablespace.test	2009-02-27 11:16:44 +0000
+++ b/mysql-test/suite/backup/t/backup_tablespace.test	2009-03-06 09:45:28 +0000
@@ -265,18 +265,31 @@ INSERT INTO t VALUES (1);
 --replace_column 1 #
 BACKUP DATABASE backup_ts TO 'ts_drop.bak';
 
+--echo
+--echo # Show tablespace info
+--query_vertical SELECT t1.tablespace_name, t1.engine, t1.tablespace_type, t2.file_name, t2.file_type FROM INFORMATION_SCHEMA.TABLESPACES AS t1, INFORMATION_SCHEMA.FILES AS t2 WHERE t1.tablespace_name = t2.tablespace_name AND t1.tablespace_name = 'TB';
+--echo
+
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+
+--echo
+--echo # Restore and verify database content
+--echo
+
+--replace_column 1 #
+RESTORE FROM 'ts_drop.bak';
+
+SHOW TABLES IN backup_ts;
+SELECT * FROM backup_ts.t;
+
+--echo
+--echo # Show tablespace info
+--query_vertical SELECT t1.tablespace_name, t1.engine, t1.tablespace_type, t2.file_name, t2.file_type FROM INFORMATION_SCHEMA.TABLESPACES AS t1, INFORMATION_SCHEMA.FILES AS t2 WHERE t1.tablespace_name = t2.tablespace_name AND t1.tablespace_name = 'TB';
+--echo
+
+--remove_file $MYSQLD_BACKUPDIR/ts_drop.bak
 DROP DATABASE backup_ts;
 DROP TABLESPACE tb ENGINE=FALCON;
 
---echo 
---echo BUG#42402 - Crashes.
---echo 
-
-#### Uncomment when 42402 is fixed ####
-#--replace_column 1 #
-# RESTORE FROM 'ts_drop.bak';
-#--remove_file $MYSQLD_BACKUPDIR/ts_drop.bak
-#DROP DATABASE backup_ts;
-#DROP TABLESPACE tb ENGINE=FALCON;
-#######################################
 

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2009-02-27 11:16:44 +0000
+++ b/sql/backup/kernel.cc	2009-03-06 09:45:28 +0000
@@ -2059,10 +2059,12 @@ int bcat_create_item(st_bstream_image_he
 
   if (item->type == BSTREAM_IT_TABLESPACE)
   {
-    if (obs::find_tablespace(thd, sobj->get_name()))
+    if (obs::find_tablespace(thd, sobj->get_name())) 
+    {
       // A tablespace with the same name exists. Nothing more to do.
       DBUG_PRINT("restore",(" skipping tablespace which exists"));
       return BSTREAM_OK;
+    }
   }
 
   // Create the object.

=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc	2009-02-26 13:53:17 +0000
+++ b/sql/si_objects.cc	2009-03-06 09:45:28 +0000
@@ -2719,6 +2719,11 @@ Obj *find_tablespace(THD *thd, const Str
 
   ed_result_set= ed_connection.use_result_set();
 
+  // Return NULL if the tablespace does not exist
+  if (ed_result_set->size() == 0)
+    return NULL;
+
+  // There can only be one tablespace with this name
   DBUG_ASSERT(ed_result_set->size() == 1);
 
   List_iterator_fast<Ed_row> row_it(*ed_result_set);

Thread
bzr commit into mysql-6.0-backup branch (jorgen.loland:2790) Bug#42402Jorgen Loland6 Mar