-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathinnodb-import-partition-1.test
105 lines (86 loc) · 3.67 KB
/
innodb-import-partition-1.test
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
#------------------------------------------------------------------------------
# Wl6868/wl6867 - Transportable tablespace with partitioned table
# Test creates table with 8192 partition and does import/export of idb files
#------------------------------------------------------------------------------
# Test take time to run due to max partitions
--source include/big_test.inc
LET MYSQLD_DATADIR = `select @@datadir`;
--disable_result_log
DROP TABLE IF EXISTS t1;
--enable_result_log
perl;
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
open FH,">$tmpd/part_table.txt";
my $partition_clause = " create table t1 (i int) engine = innodb PARTITION BY RANGE (MOD(i,8192)) (";
my $insert_clause = "INSERT INTO t1 VALUES ";
for($i=0;$i<8191;$i++){
$partition_clause = $partition_clause . " PARTITION p$i VALUES LESS THAN ($i),";
$insert_clause = $insert_clause . " ($i) ,";
}
$partition_clause = $partition_clause . " PARTITION p$i VALUES LESS THAN (8192)) ;";
$insert_clause = " $insert_clause (8191) ;";
print FH "$partition_clause\n";
print FH "$insert_clause\n";
close(FH);
EOF
# Create table with 8192(max) partitions and insert 8192 rows
# log is disabled to avoid long create/insert in result file
--disable_query_log
source $MYSQLTEST_VARDIR/tmp/part_table.txt;
--enable_query_log
SELECT COUNT(*) FROM t1;
FLUSH TABLES t1 FOR EXPORT;
--disable_result_log
perl;
require 'include/innodb-util.inc';
for($i=0;$i<=8191;$i++){
ib_backup_tablespaces("test", "t1#p#p$i");
}
EOF
--enable_result_log
UNLOCK TABLES;
DROP TABLE t1;
# Create table with 8192 partitions and insert 8192 rows
# log is disabled to avoid long create/insert in result file
--disable_query_log
source $MYSQLTEST_VARDIR/tmp/part_table.txt;
--enable_query_log
select count(*) from t1;
DELETE FROM t1;
select count(*) from t1;
ALTER TABLE t1 DISCARD PARTITION p0,p1,p2,p3,p4,p5,p6,p7,p8 TABLESPACE;
perl;
require 'include/innodb-util.inc';
ib_discard_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2","t1#p#p3","t1#p#p4","t1#p#p5","t1#p#p6","t1#p#p7","t1#p#p8");
ib_restore_tablespaces("test", "t1#p#p0", "t1#p#p1", "t1#p#p2","t1#p#p3","t1#p#p4","t1#p#p5","t1#p#p6","t1#p#p7","t1#p#p8");
EOF
ALTER TABLE t1 IMPORT PARTITION p0,p1,p2,p3,p4,p5,p6,p7,p8 TABLESPACE;
SELECT * FROM t1 PARTITION (p0,p1,p2,p3,p4,p5,p6,p7,p8) ORDER BY i;
SELECT * FROM t1 ORDER BY i;
ALTER TABLE t1 DISCARD PARTITION p9,p10 TABLESPACE;
SELECT * FROM t1 PARTITION (p0,p1,p2,p3,p4,p5,p6,p7,p8) ORDER BY i;
ALTER TABLE t1 DISCARD PARTITION all TABLESPACE;
--disable_result_log
perl;
require 'include/innodb-util.inc';
for($i=0;$i<=8191;$i++){
ib_discard_tablespaces("test", "t1#p#p$i");
ib_restore_tablespaces("test", "t1#p#p$i");
}
EOF
--enable_result_log
ALTER TABLE t1 IMPORT PARTITION all TABLESPACE;
SELECT * FROM t1 PARTITION (p0,p1,p2,p3,p4,p5,p6,p7,p8) ORDER BY i;
SELECT COUNT(*) FROM t1 ORDER BY i;
SELECT * FROM t1 WHERE i%1000 = 0 ORDER BY i;
DROP TABLE t1;
#cleanup
call mtr.add_suppression("Cannot calculate statistics for table .* because the .ibd file is missing");
call mtr.add_suppression("Cannot delete tablespace .* in DISCARD TABLESPACE. Tablespace not found");
call mtr.add_suppression("Cannot delete tablespace .* because it is not found in the tablespace memory cache.");
call mtr.add_suppression("Trying to import a tablespace, but could not open the tablespace file");
call mtr.add_suppression("Operating system error number 2 in a file operation.");
call mtr.add_suppression("The error means the system cannot find the path specified.");
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.ibd
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.cfg
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp part_table*.txt