File: innodb-import-partition-rpl.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (107 lines) | stat: -rw-r--r-- 3,576 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Testcase for import/export partition table with replication for InnoDB
# Only hash partition table is used for sanity check
--source include/master-slave.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

# Set file per table on slave
--echo # On slave
connection slave;
let $slave_per_table = `select @@innodb_file_per_table`;
set global innodb_file_per_table = 1;

--echo # On master
# Set file per table on master
connection master;
LET $MYSQLD_DATA_DIR = `select @@datadir`;
let $master_per_table = `select @@innodb_file_per_table`;
set global innodb_file_per_table = 1;
LET $MYSQLD_MASTER_DATA_DIR = `select @@datadir`;
--echo # Create partitioned table on master
CREATE TABLE t1 ( i INT ) ENGINE = InnoDB  PARTITION BY HASH(i) PARTITIONS 3;
CREATE TABLE t2 ( i INT ) ENGINE = InnoDB  PARTITION BY KEY(i) PARTITIONS 3;
INSERT INTO t1 VALUES (1),(111),(321);
INSERT INTO t2 VALUES (0),(1),(2);
FLUSH TABLES t1,t2 FOR EXPORT;
--source include/sync_slave_sql_with_master.inc

--echo # set MYSQLD_DATADIR with master datadir to copy idb and cfg files
LET MYSQLD_DATADIR = $MYSQLD_MASTER_DATA_DIR;
perl;
require 'include/innodb-util.inc';
ib_backup_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2");
ib_backup_tablespaces("test", "t2#p#p0", "t2#p#p1");
EOF

--echo # On slave
connection slave;
--echo # check table created on slave
SELECT * FROM t1;
SELECT * FROM t2;

--echo # On master
--echo # DISCARD TABLESPACE on master.It will be also discarded from slave.
connection master;
UNLOCK TABLES;
ALTER TABLE t1 DISCARD TABLESPACE;
#--source include/sync_slave_sql_with_master.inc
ALTER TABLE t2 DISCARD PARTITION p0,p1 TABLESPACE;
--source include/sync_slave_sql_with_master.inc

--echo # Copy back ibd and cfg files on master
LET MYSQLD_DATADIR = $MYSQLD_MASTER_DATA_DIR;
perl;
require 'include/innodb-util.inc';
ib_discard_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2");
ib_restore_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2");
ib_discard_tablespaces("test", "t2#p#p0", "t2#p#p1");
ib_restore_tablespaces("test", "t2#p#p0", "t2#p#p1");
EOF

--echo # Copy back ibd and cfg files on slave
connection slave;
LET $MYSQLD_SLAVE_DATA_DIR = `select @@datadir`;
LET MYSQLD_DATADIR = $MYSQLD_SLAVE_DATA_DIR;
perl;
require 'include/innodb-util.inc';
ib_discard_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2");
ib_restore_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2");
ib_discard_tablespaces("test", "t2#p#p0", "t2#p#p1");
ib_restore_tablespaces("test", "t2#p#p0", "t2#p#p1");
EOF

--echo # IMPORT TABLESPACE on master.It will be also imported on slave.
connection master;
ALTER TABLE t1 IMPORT TABLESPACE;
SELECT * FROM t1;
ALTER TABLE t2 IMPORT PARTITION p0,p1 TABLESPACE;
SELECT * FROM t2;
--source include/sync_slave_sql_with_master.inc

--echo # On slave
--echo # Verify table data on slave
connection slave;
SELECT * FROM t1;
SELECT * FROM t2;



# Cleanup
connection slave;
eval set global innodb_file_per_table = $slave_per_table;
connection master;
eval set global innodb_file_per_table = $master_per_table;
DROP TABLE t1;
DROP TABLE t2;
--source include/rpl_end.inc

call mtr.add_suppression("Got error -1 when reading table '.*'");
call mtr.add_suppression("Error: tablespace id and flags in file '.*'.*");
call mtr.add_suppression("The table .* doesn't have a corresponding tablespace, it was discarded");

--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.ibd
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.cfg
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t2*.ibd
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t2*.cfg