| 1 |
# Testcase for import/export partition table with replication for InnoDB |
| 2 |
# Only hash partition table is used for sanity check |
| 3 |
--source include/master-slave.inc |
| 4 |
|
| 5 |
--disable_warnings |
| 6 |
DROP TABLE IF EXISTS t1; |
| 7 |
--enable_warnings |
| 8 |
|
| 9 |
# Set file per table on slave |
| 10 |
--echo # On slave |
| 11 |
connection slave; |
| 12 |
let $slave_per_table = `select @@innodb_file_per_table`; |
| 13 |
set global innodb_file_per_table = 1; |
| 14 |
|
| 15 |
--echo # On master |
| 16 |
# Set file per table on master |
| 17 |
connection master; |
| 18 |
LET $MYSQLD_DATA_DIR = `select @@datadir`; |
| 19 |
let $master_per_table = `select @@innodb_file_per_table`; |
| 20 |
set global innodb_file_per_table = 1; |
| 21 |
LET $MYSQLD_MASTER_DATA_DIR = `select @@datadir`; |
| 22 |
--echo # Create partitioned table on master |
| 23 |
CREATE TABLE t1 ( i INT ) ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 3; |
| 24 |
CREATE TABLE t2 ( i INT ) ENGINE = InnoDB PARTITION BY KEY(i) PARTITIONS 3; |
| 25 |
INSERT INTO t1 VALUES (1),(111),(321); |
| 26 |
INSERT INTO t2 VALUES (0),(1),(2); |
| 27 |
FLUSH TABLES t1,t2 FOR EXPORT; |
| 28 |
--source include/sync_slave_sql_with_master.inc |
| 29 |
|
| 30 |
--echo # set MYSQLD_DATADIR with master datadir to copy idb and cfg files |
| 31 |
LET MYSQLD_DATADIR = $MYSQLD_MASTER_DATA_DIR; |
| 32 |
perl; |
| 33 |
require 'include/innodb-util.inc'; |
| 34 |
ib_backup_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2"); |
| 35 |
ib_backup_tablespaces("test", "t2#p#p0", "t2#p#p1"); |
| 36 |
EOF |
| 37 |
|
| 38 |
--echo # On slave |
| 39 |
connection slave; |
| 40 |
--echo # check table created on slave |
| 41 |
SELECT * FROM t1; |
| 42 |
SELECT * FROM t2; |
| 43 |
|
| 44 |
--echo # On master |
| 45 |
--echo # DISCARD TABLESPACE on master.It will be also discarded from slave. |
| 46 |
connection master; |
| 47 |
UNLOCK TABLES; |
| 48 |
ALTER TABLE t1 DISCARD TABLESPACE; |
| 49 |
#--source include/sync_slave_sql_with_master.inc |
| 50 |
ALTER TABLE t2 DISCARD PARTITION p0,p1 TABLESPACE; |
| 51 |
--source include/sync_slave_sql_with_master.inc |
| 52 |
|
| 53 |
--echo # Copy back ibd and cfg files on master |
| 54 |
LET MYSQLD_DATADIR = $MYSQLD_MASTER_DATA_DIR; |
| 55 |
perl; |
| 56 |
require 'include/innodb-util.inc'; |
| 57 |
ib_discard_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2"); |
| 58 |
ib_restore_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2"); |
| 59 |
ib_discard_tablespaces("test", "t2#p#p0", "t2#p#p1"); |
| 60 |
ib_restore_tablespaces("test", "t2#p#p0", "t2#p#p1"); |
| 61 |
EOF |
| 62 |
|
| 63 |
--echo # Copy back ibd and cfg files on slave |
| 64 |
connection slave; |
| 65 |
LET $MYSQLD_SLAVE_DATA_DIR = `select @@datadir`; |
| 66 |
LET MYSQLD_DATADIR = $MYSQLD_SLAVE_DATA_DIR; |
| 67 |
perl; |
| 68 |
require 'include/innodb-util.inc'; |
| 69 |
ib_discard_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2"); |
| 70 |
ib_restore_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2"); |
| 71 |
ib_discard_tablespaces("test", "t2#p#p0", "t2#p#p1"); |
| 72 |
ib_restore_tablespaces("test", "t2#p#p0", "t2#p#p1"); |
| 73 |
EOF |
| 74 |
|
| 75 |
--echo # IMPORT TABLESPACE on master.It will be also imported on slave. |
| 76 |
connection master; |
| 77 |
ALTER TABLE t1 IMPORT TABLESPACE; |
| 78 |
SELECT * FROM t1; |
| 79 |
ALTER TABLE t2 IMPORT PARTITION p0,p1 TABLESPACE; |
| 80 |
SELECT * FROM t2; |
| 81 |
--source include/sync_slave_sql_with_master.inc |
| 82 |
|
| 83 |
--echo # On slave |
| 84 |
--echo # Verify table data on slave |
| 85 |
connection slave; |
| 86 |
SELECT * FROM t1; |
| 87 |
SELECT * FROM t2; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
# Cleanup |
| 92 |
connection slave; |
| 93 |
eval set global innodb_file_per_table = $slave_per_table; |
| 94 |
connection master; |
| 95 |
eval set global innodb_file_per_table = $master_per_table; |
| 96 |
DROP TABLE t1; |
| 97 |
DROP TABLE t2; |
| 98 |
--source include/rpl_end.inc |
| 99 |
|
| 100 |
call mtr.add_suppression("Got error -1 when reading table '.*'"); |
| 101 |
call mtr.add_suppression("Error: tablespace id and flags in file '.*'.*"); |
| 102 |
call mtr.add_suppression("The table .* doesn't have a corresponding tablespace, it was discarded"); |
| 103 |
|
| 104 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.ibd |
| 105 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.cfg |
| 106 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t2*.ibd |
| 107 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t2*.cfg |