| 1 |
#------------------------------------------------------------------------------ |
| 2 |
# Wl6868/wl6867 - Transportable tablespace with partitioned table |
| 3 |
# Test creates table with 8192 partition and does import/export of idb files |
| 4 |
#------------------------------------------------------------------------------ |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
# Test take time to run due to max partitions |
| 9 |
--source include/big_test.inc |
| 10 |
|
| 11 |
LET MYSQLD_DATADIR = `select @@datadir`; |
| 12 |
|
| 13 |
--disable_result_log |
| 14 |
DROP TABLE IF EXISTS t1; |
| 15 |
--enable_result_log |
| 16 |
|
| 17 |
perl; |
| 18 |
|
| 19 |
my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp"; |
| 20 |
open FH,">$tmpd/part_table.txt"; |
| 21 |
my $partition_clause = " create table t1 (i int) engine = innodb PARTITION BY RANGE (MOD(i,8192)) ("; |
| 22 |
my $insert_clause = "INSERT INTO t1 VALUES "; |
| 23 |
for($i=0;$i<8191;$i++){ |
| 24 |
$partition_clause = $partition_clause . " PARTITION p$i VALUES LESS THAN ($i),"; |
| 25 |
$insert_clause = $insert_clause . " ($i) ,"; |
| 26 |
} |
| 27 |
$partition_clause = $partition_clause . " PARTITION p$i VALUES LESS THAN (8192)) ;"; |
| 28 |
$insert_clause = " $insert_clause (8191) ;"; |
| 29 |
print FH "$partition_clause\n"; |
| 30 |
print FH "$insert_clause\n"; |
| 31 |
close(FH); |
| 32 |
EOF |
| 33 |
|
| 34 |
# Create table with 8192(max) partitions and insert 8192 rows |
| 35 |
# log is disabled to avoid long create/insert in result file |
| 36 |
--disable_query_log |
| 37 |
source $MYSQLTEST_VARDIR/tmp/part_table.txt; |
| 38 |
--enable_query_log |
| 39 |
|
| 40 |
SELECT COUNT(*) FROM t1; |
| 41 |
FLUSH TABLES t1 FOR EXPORT; |
| 42 |
|
| 43 |
--disable_result_log |
| 44 |
perl; |
| 45 |
require 'include/innodb-util.inc'; |
| 46 |
for($i=0;$i<=8191;$i++){ |
| 47 |
ib_backup_tablespaces("test", "t1#p#p$i"); |
| 48 |
} |
| 49 |
EOF |
| 50 |
--enable_result_log |
| 51 |
|
| 52 |
UNLOCK TABLES; |
| 53 |
|
| 54 |
DROP TABLE t1; |
| 55 |
|
| 56 |
# Create table with 8192 partitions and insert 8192 rows |
| 57 |
# log is disabled to avoid long create/insert in result file |
| 58 |
--disable_query_log |
| 59 |
source $MYSQLTEST_VARDIR/tmp/part_table.txt; |
| 60 |
--enable_query_log |
| 61 |
select count(*) from t1; |
| 62 |
DELETE FROM t1; |
| 63 |
select count(*) from t1; |
| 64 |
ALTER TABLE t1 DISCARD PARTITION p0,p1,p2,p3,p4,p5,p6,p7,p8 TABLESPACE; |
| 65 |
|
| 66 |
perl; |
| 67 |
require 'include/innodb-util.inc'; |
| 68 |
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"); |
| 69 |
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"); |
| 70 |
EOF |
| 71 |
|
| 72 |
ALTER TABLE t1 IMPORT PARTITION p0,p1,p2,p3,p4,p5,p6,p7,p8 TABLESPACE; |
| 73 |
SELECT * FROM t1 PARTITION (p0,p1,p2,p3,p4,p5,p6,p7,p8) ORDER BY i; |
| 74 |
SELECT * FROM t1 ORDER BY i; |
| 75 |
ALTER TABLE t1 DISCARD PARTITION p9,p10 TABLESPACE; |
| 76 |
SELECT * FROM t1 PARTITION (p0,p1,p2,p3,p4,p5,p6,p7,p8) ORDER BY i; |
| 77 |
ALTER TABLE t1 DISCARD PARTITION all TABLESPACE; |
| 78 |
|
| 79 |
--disable_result_log |
| 80 |
perl; |
| 81 |
require 'include/innodb-util.inc'; |
| 82 |
for($i=0;$i<=8191;$i++){ |
| 83 |
ib_discard_tablespaces("test", "t1#p#p$i"); |
| 84 |
ib_restore_tablespaces("test", "t1#p#p$i"); |
| 85 |
} |
| 86 |
EOF |
| 87 |
--enable_result_log |
| 88 |
|
| 89 |
ALTER TABLE t1 IMPORT PARTITION all TABLESPACE; |
| 90 |
SELECT * FROM t1 PARTITION (p0,p1,p2,p3,p4,p5,p6,p7,p8) ORDER BY i; |
| 91 |
SELECT COUNT(*) FROM t1 ORDER BY i; |
| 92 |
SELECT * FROM t1 WHERE i%1000 = 0 ORDER BY i; |
| 93 |
DROP TABLE t1; |
| 94 |
|
| 95 |
#cleanup |
| 96 |
call mtr.add_suppression("Cannot calculate statistics for table .* because the .ibd file is missing"); |
| 97 |
call mtr.add_suppression("Cannot delete tablespace .* in DISCARD TABLESPACE. Tablespace not found"); |
| 98 |
call mtr.add_suppression("Cannot delete tablespace .* because it is not found in the tablespace memory cache."); |
| 99 |
call mtr.add_suppression("Trying to import a tablespace, but could not open the tablespace file"); |
| 100 |
call mtr.add_suppression("Operating system error number 2 in a file operation."); |
| 101 |
call mtr.add_suppression("The error means the system cannot find the path specified."); |
| 102 |
|
| 103 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.ibd |
| 104 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.cfg |
| 105 |
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp part_table*.txt |