Hi Hema,
STATUS: approved
Commentary: please see below
Hema Sridharan, 28.08.2009 22:27:
...
> 2866 Hema Sridharan 2009-08-28
> BUG#46982 (There is no test in backup suite that performs BACKUP DATABASE * to
> image)
In the future, please break long lines in the revision comments.
> The patch for this bug will add new test to backup suite that will perform
> BACKUP DATABASE * TO 'image' and RESTORE FROM 'image'
> added:
> mysql-test/suite/backup/r/backup_all.result
> mysql-test/suite/backup/t/backup_all.test
>
> per-file messages:
> mysql-test/suite/backup/r/backup_all.result
> Result file for backup_all.test
> mysql-test/suite/backup/t/backup_all.test
> New test added to backup suite which will perform BACKUP DATABASE * TO 'image'
> and
> RESTORE FROM 'image'
> === added file 'mysql-test/suite/backup/r/backup_all.result'
> --- a/mysql-test/suite/backup/r/backup_all.result 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/backup/r/backup_all.result 2009-08-28 20:27:37 +0000
> @@ -0,0 +1,73 @@
> +DROP DATABASE IF EXISTS db1;
> +DROP DATABASE IF EXISTS db2;
> +DROP DATABASE IF EXISTS db3;
> +# Create database
> +CREATE DATABASE db1;
> +CREATE DATABASE db2;
> +CREATE DATABASE db3;
> +# Create tables in database
> +CREATE TABLE db1.t1(id INT);
> +CREATE TABLE db1.t2(a CHAR(5));
> +CREATE TABLE db2.t1(id INT);
> +CREATE TABLE db2.t2(a CHAR(5));
> +CREATE TABLE db3.t1(id INT);
> +CREATE TABLE db3.t2(a CHAR(5));
> +# Check the databases and tables
> +SHOW DATABASES;
> +Database
> +information_schema
> +db1
> +db2
> +db3
> +mtr
> +mysql
> +test
> +SHOW TABLES FROM db1;
> +Tables_in_db1
> +t1
> +t2
> +SHOW TABLES FROM db2;
> +Tables_in_db2
> +t1
> +t2
> +SHOW TABLES FROM db3;
> +Tables_in_db3
> +t1
> +t2
> +# Perform backup
> +BACKUP DATABASE * TO 'alldb.bak';
> +backup_id
> +#
> +# Drop database and perform restore
> +DROP DATABASE db1;
> +DROP DATABASE db2;
> +DROP DATABASE db3;
> +RESTORE FROM 'alldb.bak' OVERWRITE;
> +backup_id
> +#
> +# Check that all the databases are restored
> +SHOW DATABASES;
> +Database
> +information_schema
> +db1
> +db2
> +db3
> +mtr
> +mysql
> +test
> +SHOW TABLES FROM db1;
> +Tables_in_db1
> +t1
> +t2
> +SHOW TABLES FROM db2;
> +Tables_in_db2
> +t1
> +t2
> +SHOW TABLES FROM db3;
> +Tables_in_db3
> +t1
> +t2
> +# Test clean-up section
> +DROP DATABASE db1;
> +DROP DATABASE db2;
> +DROP DATABASE db3;
>
> === added file 'mysql-test/suite/backup/t/backup_all.test'
> --- a/mysql-test/suite/backup/t/backup_all.test 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/backup/t/backup_all.test 2009-08-28 20:27:37 +0000
> @@ -0,0 +1,77 @@
> +# This test is performed for BUG#46982
> +# The primary goal of this test is to execute BACKUP DATABASE * TO 'image' and
> +# then RESTORE FROM 'image'
> +
> +--source include/not_embedded.inc
> +
> +--disable_warnings
> +DROP DATABASE IF EXISTS db1;
> +DROP DATABASE IF EXISTS db2;
> +DROP DATABASE IF EXISTS db3;
> +
> +let $MYSQLD_BACKUPDIR= `select @@backupdir`;
> +--error 0,1
> +remove_file $MYSQLD_BACKUPDIR/alldb.bak;
> +--enable_warnings
> +
> +--echo # Create database
> +
> +CREATE DATABASE db1;
> +CREATE DATABASE db2;
> +CREATE DATABASE db3;
> +
> +--echo # Create tables in database
> +
> +CREATE TABLE db1.t1(id INT);
> +CREATE TABLE db1.t2(a CHAR(5));
> +
> +CREATE TABLE db2.t1(id INT);
> +CREATE TABLE db2.t2(a CHAR(5));
> +
> +CREATE TABLE db3.t1(id INT);
> +CREATE TABLE db3.t2(a CHAR(5));
> +
> +--echo # Check the databases and tables
> +
> +SHOW DATABASES;
> +SHOW TABLES FROM db1;
> +SHOW TABLES FROM db2;
> +SHOW TABLES FROM db3;
> +
> +--echo # Perform backup
> +# BACKUP DATABASE * performs backup of all the databases in the server
> +
> +--replace_column 1 #
> +BACKUP DATABASE * TO 'alldb.bak';
> +
> +--echo # Drop database and perform restore
> +
> +DROP DATABASE db1;
> +DROP DATABASE db2;
> +DROP DATABASE db3;
> +
> +# Note that restore will produce warnings because of BUG#46765
> +# BUG#46765 :Restore throws warnings when performing backup of test database
> +# One this bug is fixed, restore should not produce any warning. Also remove
> +# disable_warnings, enable_warnings and replace_regex from below lines while
> +# performing restore.
> +
> +--disable_warnings
> +--replace_column 1 #
> +--replace_regex /[0000-9999]+/#/
> +RESTORE FROM 'alldb.bak' OVERWRITE;
> +--enable_warnings
An alternative could have been to let the warnings go to the result file
and later fix the result file. (Just a comment, no need to change.)
I guess that replace_regex would not be required here as you suppress
all warnings and there is no output that requires replacing. (Just a
comment, no need to change.)
I guess the "OVERWRITE" option is required for the mtr and test
databases, perhaps even the mysql database? Would it be possible to
leave away "OVERWRITE", if you drop these databases explicitly?
...
Regards
Ingo
--
Ingo Strüwing, Database Group
Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring HRB München 161028