List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:February 27 2009 11:17am
Subject:bzr push into mysql-6.0-backup branch (jorgen.loland:2779 to 2780) Bug#33569
View as plain text  
 2780 Jorgen Loland	2009-02-27
      Bug#33569 - Backup: tablespace not restored
            
      Previously, RESTORE had a lot of restrictions for when an existing tablespace the restore depended upon could be used. Basically, the "create tablespace" statements had to be equal case-sensitive Strings, or RESTORE would error.
            
      There is no need for this kind of restriction. If RESTORE requires a tablespace 'x' to restore a table, it should use the existing one if a tablespace with name 'x' exists. Otherwise, the tablespace should be created using the backed up definition.
modified:
  mysql-test/suite/backup/r/backup_object_count.result
  mysql-test/suite/backup/r/backup_tablespace.result
  mysql-test/suite/backup/t/backup_object_count.test
  mysql-test/suite/backup/t/backup_tablespace.test
  sql/backup/kernel.cc

 2779 Ingo Struewing	2009-02-27
      Post-Pushbuild fix.
      Fixed compiler warnings.
modified:
  client/backup_stream.c
  client/mysqlbackup.cc

=== modified file 'mysql-test/suite/backup/r/backup_object_count.result'
--- a/mysql-test/suite/backup/r/backup_object_count.result	2009-02-16 12:20:31 +0000
+++ b/mysql-test/suite/backup/r/backup_object_count.result	2009-02-27 11:16:44 +0000
@@ -78,3 +78,4 @@ num_objects
 #
 DROP USER bup_user1;
 DROP DATABASE objectcount;
+DROP TABLESPACE ts ENGINE=FALCON;

=== modified file 'mysql-test/suite/backup/r/backup_tablespace.result'
--- a/mysql-test/suite/backup/r/backup_tablespace.result	2009-02-02 11:17:53 +0000
+++ b/mysql-test/suite/backup/r/backup_tablespace.result	2009-02-27 11:16:44 +0000
@@ -1,8 +1,10 @@
-call mtr.add_suppression("Restore: Tablespace .* needed by tables being restored, but the current tablespace definition differs");
 DROP TABLE IF EXISTS backup_ts.not_ts;
 DROP TABLE IF EXISTS backup_ts.has_ts;
 DROP DATABASE IF EXISTS backup_ts;
 CREATE DATABASE backup_ts;
+#
+# Test 1 - Test backup of database with a table that uses a tablespace
+#
 Test 1:
 Create a tablespace.
 CREATE TABLESPACE bup_ts ADD DATAFILE 'bup_ts.dat' COMMENT = 'test tablespace backup' ENGINE=FALCON;
@@ -45,13 +47,169 @@ id	comment
 54	Table has a tablespace 54
 55	Table has a tablespace 55
 DROP DATABASE backup_ts;
-Test 2:
-Alter the tablespace.
-DROP TABLESPACE bup_ts ENGINE=FALCON;
-CREATE TABLESPACE bup_ts ADD DATAFILE 'different.dat' ENGINE=FALCON;
-Now restore the database.
-RESTORE FROM 'backup_ts.bak';
-ERROR HY000: Tablespace `BUP_TS` needed by tables being restored, but the current tablespace definition differs from how it was when backup was made.
-Cleanup
-DROP DATABASE IF EXISTS backup_ts;
-DROP TABLESPACE bup_ts ENGINE=FALCON;
+#
+# Test 2 - Test that restore of tablespaces work when the 
+#          tablespace has been modified since backup was made
+#
+# Test 2.1: Backup ts with lowercase name, restore after 
+# dropping it and creating a ts with uppercase name
+#
+Create ts with lowercase name
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+Create a database using the ts
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+Backup database
+
+BACKUP DATABASE backup_ts TO 'ts_lc.bak';
+backup_id
+#
+Drop database and recreate ts with uppercase name
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE TB ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+Restore database
+RESTORE FROM 'ts_lc.bak';
+backup_id
+#
+
+Do inverse: Backup with uppercase ts, restore with lowercase ts
+
+BACKUP DATABASE backup_ts TO 'ts_uc.bak';
+backup_id
+#
+Drop database and recreate ts with lowecase name
+DROP DATABASE backup_ts;
+DROP TABLESPACE TB ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+Restore database
+
+RESTORE FROM 'ts_uc.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+#
+# Test 2.2: Backup ts with lowercase filename, restore after 
+# dropping it and creating a ts with uppercase filename
+#
+Create ts with lowercase filename
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+Create a database using the ts
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+Backup database
+
+BACKUP DATABASE backup_ts TO 'ts_lcfile.bak';
+backup_id
+#
+Drop database and recreate ts with uppercase filename
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'TBLSPACE' ENGINE=FALCON;
+
+Restore database
+
+RESTORE FROM 'ts_lcfile.bak';
+backup_id
+#
+
+Do inverse: Backup with uppercase filename, 
+restore with lowercase ts filename
+
+BACKUP DATABASE backup_ts TO 'ts_ucfile.bak';
+backup_id
+#
+Drop database and recreate ts with lowercase filename
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+Restore database
+
+RESTORE FROM 'ts_ucfile.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+#
+# Test 2.3: Backup ts, restore after dropping it and creating a ts with
+# a different extent_size
+#
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+BACKUP DATABASE backup_ts TO 'ts_extent.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' EXTENT_SIZE = 1024 ENGINE=FALCON;
+RESTORE FROM 'ts_extent.bak';
+backup_id
+#
+
+Do inverse: Backup with extent_size 1024, restore without setting it
+
+BACKUP DATABASE backup_ts TO 'ts_extent2.bak';
+backup_id
+#
+Drop database and recreate ts with lowecase name
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+Restore database
+
+RESTORE FROM 'ts_extent2.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+#
+# Test 2.4: Backup ts, restore after dropping it and creating a ts with
+# a different filename
+#
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+BACKUP DATABASE backup_ts TO 'ts_newfname.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace2' ENGINE=FALCON;
+RESTORE FROM 'ts_newfname.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+
+# Test 3: Restore after deleting a tablespace the backed up database 
+#         depends on.
+
+CREATE TABLESPACE `TB` ADD DATAFILE 'tblspace' ENGINE=FALCON;
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+BACKUP DATABASE backup_ts TO 'ts_drop.bak';
+backup_id
+#
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+
+BUG#42402 - Crashes.
+

=== modified file 'mysql-test/suite/backup/t/backup_object_count.test'
--- a/mysql-test/suite/backup/t/backup_object_count.test	2009-02-16 12:20:31 +0000
+++ b/mysql-test/suite/backup/t/backup_object_count.test	2009-02-27 11:16:44 +0000
@@ -110,4 +110,5 @@ SELECT num_objects FROM mysql.backup_his
 
 DROP USER bup_user1;
 DROP DATABASE objectcount;
+DROP TABLESPACE ts ENGINE=FALCON;
 --remove_file $MYSQLD_BACKUPDIR/objectcount.bak

=== modified file 'mysql-test/suite/backup/t/backup_tablespace.test'
--- a/mysql-test/suite/backup/t/backup_tablespace.test	2009-02-24 20:57:21 +0000
+++ b/mysql-test/suite/backup/t/backup_tablespace.test	2009-02-27 11:16:44 +0000
@@ -8,8 +8,6 @@
 --source include/have_falcon.inc
 --source include/not_embedded.inc
 
-call mtr.add_suppression("Restore: Tablespace .* needed by tables being restored, but the current tablespace definition differs");
-
 let $MYSQLD_BACKUPDIR=`select @@backupdir`;
 
 --disable_warnings
@@ -28,9 +26,9 @@ DROP DATABASE IF EXISTS backup_ts;
 
 CREATE DATABASE backup_ts;
 
-#
-# Test 1 - Test backup of database with a table that uses a tablespace
-#
+--echo #
+--echo # Test 1 - Test backup of database with a table that uses a tablespace
+--echo #
 --echo Test 1:
 --echo Create a tablespace.
 CREATE TABLESPACE bup_ts ADD DATAFILE 'bup_ts.dat' COMMENT = 'test tablespace backup' ENGINE=FALCON;
@@ -72,28 +70,213 @@ SELECT * FROM backup_ts.has_ts;
 
 DROP DATABASE backup_ts;
 
-#
-# Test 2 - Test restore of database throws error when tablespace
-#          has been altered.
-#
---echo Test 2:
---echo Alter the tablespace.
-DROP TABLESPACE bup_ts ENGINE=FALCON;
-CREATE TABLESPACE bup_ts ADD DATAFILE 'different.dat' ENGINE=FALCON;
+--echo #
+--echo # Test 2 - Test that restore of tablespaces work when the 
+--echo #          tablespace has been modified since backup was made
+
+--echo #
+--echo # Test 2.1: Backup ts with lowercase name, restore after 
+--echo # dropping it and creating a ts with uppercase name
+--echo #
+
+--echo Create ts with lowercase name
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+--echo Create a database using the ts
+CREATE DATABASE backup_ts;
+USE backup_ts;
 
-# Restore the database and ensure there is an error.
---echo Now restore the database.
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+--echo
+--echo Backup database
+--echo
 --replace_column 1 #
---error ER_BACKUP_TS_CHANGE
-RESTORE FROM 'backup_ts.bak';
+BACKUP DATABASE backup_ts TO 'ts_lc.bak';
 
-# Must drop database before tablespace.
---echo Cleanup
---disable_warnings
-DROP DATABASE IF EXISTS backup_ts;
---enable_warnings
-DROP TABLESPACE bup_ts ENGINE=FALCON;
+--echo Drop database and recreate ts with uppercase name
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE TB ADD DATAFILE 'tblspace' ENGINE=FALCON;
 
---error 0,1
---remove_file $MYSQLD_BACKUPDIR/backup_ts.bak
+--echo
+--echo Restore database
+--replace_column 1 #
+RESTORE FROM 'ts_lc.bak';
+
+--echo
+--echo Do inverse: Backup with uppercase ts, restore with lowercase ts
+--echo
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO 'ts_uc.bak';
+
+--echo Drop database and recreate ts with lowecase name
+DROP DATABASE backup_ts;
+DROP TABLESPACE TB ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+--echo
+--echo Restore database
+--echo
+--replace_column 1 #
+RESTORE FROM 'ts_uc.bak';
+
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+--remove_file $MYSQLD_BACKUPDIR/ts_lc.bak
+--remove_file $MYSQLD_BACKUPDIR/ts_uc.bak
+
+--echo #
+--echo # Test 2.2: Backup ts with lowercase filename, restore after 
+--echo # dropping it and creating a ts with uppercase filename
+--echo #
+
+--echo Create ts with lowercase filename
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+--echo Create a database using the ts
+CREATE DATABASE backup_ts;
+USE backup_ts;
+
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+--echo
+--echo Backup database
+--echo
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO 'ts_lcfile.bak';
+
+--echo Drop database and recreate ts with uppercase filename
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'TBLSPACE' ENGINE=FALCON;
+
+--echo
+--echo Restore database
+--echo
+--replace_column 1 #
+RESTORE FROM 'ts_lcfile.bak';
+
+--echo
+--echo Do inverse: Backup with uppercase filename, 
+--echo restore with lowercase ts filename
+--echo
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO 'ts_ucfile.bak';
+
+--echo Drop database and recreate ts with lowercase filename
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+--echo
+--echo Restore database
+--echo
+--replace_column 1 #
+RESTORE FROM 'ts_ucfile.bak';
+
+--remove_file $MYSQLD_BACKUPDIR/ts_lcfile.bak
+--remove_file $MYSQLD_BACKUPDIR/ts_ucfile.bak
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+
+
+--echo #
+--echo # Test 2.3: Backup ts, restore after dropping it and creating a ts with
+--echo # a different extent_size
+--echo #
+
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO 'ts_extent.bak';
+
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' EXTENT_SIZE = 1024 ENGINE=FALCON;
+
+--replace_column 1 #
+RESTORE FROM 'ts_extent.bak';
+
+--echo
+--echo Do inverse: Backup with extent_size 1024, restore without setting it
+--echo
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO 'ts_extent2.bak';
+
+--echo Drop database and recreate ts with lowecase name
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+
+--echo
+--echo Restore database
+--echo
+--replace_column 1 #
+RESTORE FROM 'ts_extent2.bak';
+
+--remove_file $MYSQLD_BACKUPDIR/ts_extent.bak
+--remove_file $MYSQLD_BACKUPDIR/ts_extent2.bak
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+
+--echo #
+--echo # Test 2.4: Backup ts, restore after dropping it and creating a ts with
+--echo # a different filename
+--echo #
+
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace' ENGINE=FALCON;
+CREATE DATABASE backup_ts;
+USE backup_ts;
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO 'ts_newfname.bak';
+
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+CREATE TABLESPACE tb ADD DATAFILE 'tblspace2' ENGINE=FALCON;
+
+--replace_column 1 #
+RESTORE FROM 'ts_newfname.bak';
+
+--remove_file $MYSQLD_BACKUPDIR/ts_newfname.bak
+DROP DATABASE backup_ts;
+DROP TABLESPACE tb ENGINE=FALCON;
+
+--echo
+--echo # Test 3: Restore after deleting a tablespace the backed up database 
+--echo #         depends on.
+--echo
+
+CREATE TABLESPACE `TB` ADD DATAFILE 'tblspace' ENGINE=FALCON;
+CREATE DATABASE backup_ts;
+USE backup_ts;
+
+CREATE TABLE t (s1 INT) ENGINE=FALCON TABLESPACE tb;
+INSERT INTO t VALUES (1);
+
+--replace_column 1 #
+BACKUP DATABASE backup_ts TO '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-20 16:40:19 +0000
+++ b/sql/backup/kernel.cc	2009-02-27 11:16:44 +0000
@@ -2059,34 +2059,10 @@ int bcat_create_item(st_bstream_image_he
 
   if (item->type == BSTREAM_IT_TABLESPACE)
   {
-    Obj *ts= obs::find_tablespace(thd, sobj->get_name());
-
-    if (ts)
-    {
-      /*
-        A tablespace with the same name exists. We have to check if other
-        attributes are the same as they were.
-      */
-
-      if (obs::compare_tablespace_attributes(ts, sobj))
-      {
-        /* The tablespace is the same. There is nothing more to do. */
-        DBUG_PRINT("restore",(" skipping tablespace which exists"));
-        return BSTREAM_OK;
-      }
-
-      /*
-        A tablespace with the same name exists, but it has been changed
-        since backup.  We can't re-create the original tablespace used by
-        tables being restored. We report this and cancel restore process.
-      */
-
-      DBUG_PRINT("restore",
-                 (" tablespace has changed on the server - aborting"));
-      log.report_error(ER_BACKUP_TS_CHANGE, desc);
-      delete ts;
-      return BSTREAM_ERROR;
-    }
+    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.

Thread
bzr push into mysql-6.0-backup branch (jorgen.loland:2779 to 2780) Bug#33569Jorgen Loland27 Feb