#At file:///ext/mysql/bzr/backup/bug36933/
2717 Rafal Somla 2008-10-24
BUG#36933, BUG#34480, BUG#33567 (Backup: snapshot error + crash if double backup)
Before: When user specified the same database twice in the BACKUP DATABASE statement,
it was included twice in the backup image. This lead to a host of problems.
After: BACKUP DATABASE will ignore duplicates in the database list. Each database,
together with its objects, will be included only once in the produced backup image.
modified:
mysql-test/suite/backup/r/backup.result
mysql-test/suite/backup/t/backup.test
sql/backup/backup_info.cc
sql/backup/image_info.cc
sql/backup/image_info.h
per-file messages:
mysql-test/suite/backup/t/backup.test
- Add primary key to t1_blob table to cover the scenario described in BUG#36933 report.
- In one of the BACKUP commands, repeat twice a database containing table with a primary key and a blob.
sql/backup/backup_info.cc
When iterating over the list of databases specified for backup, ignore repeated names.
sql/backup/image_info.cc
Mark has_db() method as const.
sql/backup/image_info.h
Mark has_db() method as const.
=== modified file 'mysql-test/suite/backup/r/backup.result'
--- a/mysql-test/suite/backup/r/backup.result 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup.result 2008-10-24 11:23:09 +0000
@@ -172,7 +172,7 @@ PRIMARY KEY (`a`)
) ENGINE=INNODB DEFAULT CHARSET=latin1;
CREATE TABLE bup_default.t1 (a int) engine=innodb;
CREATE TABLE bup_default.t2 (a int) engine=MYISAM;
-CREATE TABLE bup_default.t1_blob (a int, b text) engine=innodb;
+CREATE TABLE bup_default.t1_blob (a int, b text, primary key (a)) engine=innodb;
INSERT INTO bup_default.wide VALUES (
NULL,
"This is column b pass 01",
@@ -350,7 +350,7 @@ Running the client:
Chuck@linux:~> mysql -uroot -p
Enter password:
-BACKUP DATABASE bup_default TO "bup_default.bak";
+BACKUP DATABASE bup_default, bup_default TO "bup_default.bak";
backup_id
#
DROP DATABASE bup_default;
=== modified file 'mysql-test/suite/backup/t/backup.test'
--- a/mysql-test/suite/backup/t/backup.test 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup.test 2008-10-24 11:23:09 +0000
@@ -229,7 +229,7 @@ CREATE TABLE bup_default.wide (
CREATE TABLE bup_default.t1 (a int) engine=innodb;
CREATE TABLE bup_default.t2 (a int) engine=MYISAM;
-CREATE TABLE bup_default.t1_blob (a int, b text) engine=innodb;
+CREATE TABLE bup_default.t1_blob (a int, b text, primary key (a)) engine=innodb;
# Insert some data.
@@ -327,8 +327,13 @@ SELECT COUNT(*) FROM bup_default.t1_blob
SELECT COUNT(*) FROM bup_default.wide;
--query_vertical SELECT * FROM bup_default.wide;
+#
+# When backing up, include bup_default database twice in the list to check that BACKUP will ignore
+# second occurence (BUG#36933, BUG#34480, BUG#33567).
+#
+
--replace_column 1 #
-BACKUP DATABASE bup_default TO "bup_default.bak";
+BACKUP DATABASE bup_default, bup_default TO "bup_default.bak";
# Now restore the database and then check to make sure the data is there.
=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc 2008-10-24 08:11:18 +0000
+++ b/sql/backup/backup_info.cc 2008-10-24 11:23:09 +0000
@@ -543,6 +543,10 @@ int Backup_info::add_dbs(List< ::LEX_STR
while ((s= it++))
{
backup::String db_name(*s);
+
+ // Ignore the database if it has already been inserted into the catalogue.
+ if (has_db(db_name))
+ continue;
if (is_internal_db_name(&db_name))
{
=== modified file 'sql/backup/image_info.cc'
--- a/sql/backup/image_info.cc 2008-10-14 12:08:56 +0000
+++ b/sql/backup/image_info.cc 2008-10-24 11:23:09 +0000
@@ -206,7 +206,7 @@ int Image_info::add_snapshot(Snapshot_in
/**
Check if catalogue contains given database.
*/
-bool Image_info::has_db(const String &db_name)
+bool Image_info::has_db(const String &db_name) const
{
for (uint n=0; n < m_dbs.count() ; ++n)
if (m_dbs[n] && m_dbs[n]->name() == db_name)
=== modified file 'sql/backup/image_info.h'
--- a/sql/backup/image_info.h 2008-10-15 15:38:28 +0000
+++ b/sql/backup/image_info.h 2008-10-24 11:23:09 +0000
@@ -83,7 +83,7 @@ public: // public interface
// Examine contents of the catalogue.
- bool has_db(const String&);
+ bool has_db(const String&) const;
// Retrieve objects using their coordinates.