2731 Ingo Struewing 2008-12-05 [merge]
auto-merge
added:
mysql-test/suite/backup_engines/r/backup_partition.result
mysql-test/suite/backup_engines/t/backup_partition.test
modified:
mysql-test/suite/backup/r/backup_default.result
mysql-test/suite/backup/t/backup_default.test
sql/backup/backup_info.cc
2730 Jorgen Loland 2008-11-28 [merge]
Merge mysql-6.0-backup -> mysql-6.0-backup-merge
modified:
sql/backup/kernel.cc
sql/backup/logger.cc
sql/share/errmsg.txt
=== modified file 'mysql-test/suite/backup/r/backup_default.result'
--- a/mysql-test/suite/backup/r/backup_default.result 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_default.result 2008-12-04 13:04:16 +0000
@@ -29,33 +29,20 @@ id name city
DROP DATABASE db1;
Server should not crash for backup using default driver
-Partitioned Falcon tables
-Test for bug#33566, bug#36792
+Mix of tables
CREATE DATABASE db1;
USE db1;
CREATE TABLE partition_table (
int_column int(11),
char_column char(5))
-engine=falcon
+ENGINE=myisam
PARTITION BY HASH (int_column);
INSERT INTO partition_table VALUES (0,'pVtIa');
INSERT INTO partition_table VALUES (5,'jTfSg');
INSERT INTO partition_table VALUES (20,'UezFi');
INSERT INTO partition_table VALUES (25,'cxmeH');
INSERT INTO partition_table VALUES (65,'lIuNS');
-testing content in restored tables
-SELECT * FROM partition_table ORDER BY int_column;
-int_column char_column
-0 pVtIa
-5 jTfSg
-20 UezFi
-25 cxmeH
-65 lIuNS
-
-Server should not crash for backup using default driver
-Mix of tables
-
CREATE TABLE csv_table(
id int NOT NULL,
name char(20) NOT NULL,
@@ -67,6 +54,33 @@ i int,
v varchar(20))
ENGINE=myisam;
INSERT INTO myisam_table VALUES(1,'v1'),(2,'v2'),(3,'v3');
+backup on mixed table database
+BACKUP DATABASE db1 to 'bup_mixed.bak';
+backup_id
+#
+DROP DATABASE db1;
+restore on mixed table database
+RESTORE FROM 'bup_mixed.bak';
+backup_id
+#
+testing content in restored tables
+SELECT * FROM partition_table ORDER BY int_column;
+int_column char_column
+0 pVtIa
+5 jTfSg
+20 UezFi
+25 cxmeH
+65 lIuNS
+SELECT * FROM csv_table ORDER BY id;
+id name city
+1 aa1 bb1
+2 aa2 bb2
+3 aa3 bb3
+SELECT * FROM myisam_table ORDER BY i;
+i v
+1 v1
+2 v2
+3 v3
*** CLEANUP ****
=== modified file 'mysql-test/suite/backup/t/backup_default.test'
--- a/mysql-test/suite/backup/t/backup_default.test 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_default.test 2008-12-04 13:04:16 +0000
@@ -43,17 +43,17 @@ DROP DATABASE db1;
--echo
--echo Server should not crash for backup using default driver
---echo Partitioned Falcon tables
---echo Test for bug#33566, bug#36792
+--echo Mix of tables
--echo
CREATE DATABASE db1;
USE db1;
+# create partitioned MyISAM table - will use default driver
CREATE TABLE partition_table (
int_column int(11),
char_column char(5))
-engine=falcon
+ENGINE=myisam
PARTITION BY HASH (int_column);
INSERT INTO partition_table VALUES (0,'pVtIa');
@@ -62,30 +62,7 @@ INSERT INTO partition_table VALUES (20,'
INSERT INTO partition_table VALUES (25,'cxmeH');
INSERT INTO partition_table VALUES (65,'lIuNS');
-#
-# This portion of the test has been disabled. See BUG#39017
-#
-#--echo backup on partitioned falcon
-#--replace_column 1 #
-#BACKUP DATABASE db1 to 'bup_falcon.bak';
-#
-#DROP DATABASE db1;
-#
-#--echo restore on partitioned falcon
-#--replace_column 1 #
-#RESTORE FROM 'bup_falcon.bak';
-
---echo testing content in restored tables
-SELECT * FROM partition_table ORDER BY int_column;
-
-
---echo
---echo Server should not crash for backup using default driver
---echo Mix of tables
---echo
-
-# partition_table already exists in the database
-# re-create the csv_table
+# create CSV table - will use default driver
CREATE TABLE csv_table(
id int NOT NULL,
name char(20) NOT NULL,
@@ -102,23 +79,20 @@ ENGINE=myisam;
INSERT INTO myisam_table VALUES(1,'v1'),(2,'v2'),(3,'v3');
-#
-# This portion of the test has been disabled. See BUG#39017
-#
-#--echo backup on mixed table database
-#--replace_column 1 #
-#BACKUP DATABASE db1 to 'bup_mixed.bak';
-#
-#DROP DATABASE db1;
-#
-#--echo restore on mixed table database
-#--replace_column 1 #
-#RESTORE FROM 'bup_mixed.bak';
-#
-#--echo testing content in restored tables
-#SELECT * FROM partition_table ORDER BY int_column;
-#SELECT * FROM csv_table ORDER BY id;
-#SELECT * FROM myisam_table ORDER BY i;
+--echo backup on mixed table database
+--replace_column 1 #
+BACKUP DATABASE db1 to 'bup_mixed.bak';
+
+DROP DATABASE db1;
+
+--echo restore on mixed table database
+--replace_column 1 #
+RESTORE FROM 'bup_mixed.bak';
+
+--echo testing content in restored tables
+SELECT * FROM partition_table ORDER BY int_column;
+SELECT * FROM csv_table ORDER BY id;
+SELECT * FROM myisam_table ORDER BY i;
# Test cleanup section
=== added file 'mysql-test/suite/backup_engines/r/backup_partition.result'
--- a/mysql-test/suite/backup_engines/r/backup_partition.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/r/backup_partition.result 2008-12-04 13:04:16 +0000
@@ -0,0 +1,43 @@
+#
+# Creating databases
+#
+CREATE DATABASE backup_part;
+CREATE TABLE backup_part.t1 (
+t1_autoinc INTEGER NOT NULL AUTO_INCREMENT,
+t1_uuid CHAR(36),
+PRIMARY KEY (t1_autoinc))
+PARTITION BY HASH (t1_autoinc);
+INSERT INTO backup_part.t1(t1_uuid) VALUES ('aaa'),('bbb'),('ccc'),('ddd');
+# Show content
+SELECT * FROM backup_part.t1 ORDER BY t1_autoinc;
+t1_autoinc t1_uuid
+1 aaa
+2 bbb
+3 ccc
+4 ddd
+#
+# Perform backup
+#
+# Show drivers.
+
+SELECT count(*) FROM mysql.backup_history WHERE drivers LIKE 'FILTERED DRIVER' AND backup_id=FILTERED ID;
+count(*)
+1
+
+#
+# Restore and show content
+#
+RESTORE FROM 'partition.bak' OVERWRITE;
+backup_id
+#
+
+SELECT * FROM backup_part.t1 ORDER BY t1_autoinc;
+t1_autoinc t1_uuid
+1 aaa
+2 bbb
+3 ccc
+4 ddd
+#
+# Cleanup
+#
+DROP DATABASE backup_part;
=== added file 'mysql-test/suite/backup_engines/t/backup_partition.test'
--- a/mysql-test/suite/backup_engines/t/backup_partition.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/backup_engines/t/backup_partition.test 2008-12-05 07:30:27 +0000
@@ -0,0 +1,70 @@
+#
+# This test is designed to test that BACKUP selects the best available
+# driver for partitioned tables. The storage engines should use these
+# drivers:
+#
+# Partitioned Falcon table -> Snapshot
+# Partitioned InnoDB table -> Snapshot
+# All other partitioned tables -> Default
+#
+
+--source include/have_partition.inc
+--source include/not_embedded.inc
+
+# Find expected backup driver for the current storage engine.
+
+let $exp_drv= Default;
+if (`select @@storage_engine = 'falcon'`) { let $exp_drv= Snapshot; }
+if (`select @@storage_engine = 'innodb'`) { let $exp_drv= Snapshot; }
+
+# Uncomment the line below and run the test with --force flag
+# if you want to verify that expected driver is correct
+#echo $exp_drv;
+
+--echo #
+--echo # Creating databases
+--echo #
+CREATE DATABASE backup_part;
+
+CREATE TABLE backup_part.t1 (
+ t1_autoinc INTEGER NOT NULL AUTO_INCREMENT,
+ t1_uuid CHAR(36),
+ PRIMARY KEY (t1_autoinc))
+PARTITION BY HASH (t1_autoinc);
+
+INSERT INTO backup_part.t1(t1_uuid) VALUES ('aaa'),('bbb'),('ccc'),('ddd');
+
+--echo # Show content
+SELECT * FROM backup_part.t1 ORDER BY t1_autoinc;
+
+--echo #
+--echo # Perform backup
+--replace_column 1 #
+let $bup_id= `BACKUP DATABASE backup_part TO 'partition.bak'`;
+
+--echo #
+--echo # Show drivers.
+
+--echo
+# Count of expected driver for this backup_id should be 1
+# Replace exp_drv and backup_id in query because it will vary
+replace_regex /'.*'.*/'FILTERED DRIVER' AND backup_id=FILTERED ID/ ;
+--eval SELECT count(*) FROM mysql.backup_history WHERE drivers LIKE '$exp_drv' AND backup_id=$bup_id
+--echo
+
+--echo #
+--echo # Restore and show content
+--echo #
+
+--replace_column 1 #
+RESTORE FROM 'partition.bak' OVERWRITE;
+--echo
+SELECT * FROM backup_part.t1 ORDER BY t1_autoinc;
+
+--echo #
+--echo # Cleanup
+--echo #
+
+DROP DATABASE backup_part;
+
+--remove_file $MYSQLTEST_VARDIR/master-data/partition.bak
=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc 2008-11-25 17:44:19 +0000
+++ b/sql/backup/backup_info.cc 2008-12-04 15:25:48 +0000
@@ -8,6 +8,7 @@
*/
#include "../mysql_priv.h"
+#include "../ha_partition.h"
#include "backup_info.h"
#include "backup_kernel.h"
@@ -34,6 +35,50 @@ storage_engine_ref get_storage_engine(TH
if (table)
{
se= plugin_ref_to_se_ref(table->s->db_plugin);
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ /*
+ Further check for underlying storage engine is needed
+ if table is partitioned
+ */
+
+ storage_engine_ref se_tmp= NULL;
+
+ if (table->part_info)
+ {
+ partition_info *p_info= table->part_info;
+ List_iterator<partition_element> p_it(p_info->partitions);
+ partition_element *p_el;
+
+ while ((p_el= p_it++))
+ {
+ if (!se_tmp)
+ {
+ se_tmp= hton2plugin[p_el->engine_type->slot];
+ ::handlerton *h= se_hton(se_tmp);
+
+ /*
+ Native drivers don't support partitioning. Let Falcon and
+ InnoDB use Snapshot driver; all other storage engines use
+ Default.
+ */
+ if (h->start_consistent_snapshot == NULL)
+ goto close; // This is not a Falcon or InnoDB storage engine
+
+ continue;
+ }
+
+ // use Default driver if partitions have different storage engines
+ if (se_tmp != hton2plugin[p_el->engine_type->slot])
+ goto close;
+ };
+
+ se= se_tmp;
+ }
+#endif
+
+ close:
+
::intern_close_table(table);
my_free(table, MYF(0));
}
| Thread |
|---|
| • bzr push into mysql-6.0 branch (ingo.struewing:2730 to 2731) | Ingo Struewing | 5 Dec |