Debian Codegraph @

mysql-test/suite/encryption/t/innodb-discard-import.test

raw
1 -- source include/have_innodb.inc
2 -- source include/innodb_page_size_small.inc
3 -- source include/have_file_key_management_plugin.inc
4
5 #
6 # MDEV-8770: Incorrect error message when importing page compressed tablespace
7 #
8
9 call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded.");
10 call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .* for how to resolve the issue.");
11
12 let $innodb_compression_algo = `SELECT @@innodb_compression_algorithm`;
13 SET GLOBAL innodb_compression_algorithm = 1;
14
15 --let $MYSQLD_TMPDIR = `SELECT @@tmpdir`
16 --let $MYSQLD_DATADIR = `SELECT @@datadir`
17 --let SEARCH_RANGE = 10000000
18 --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd
19 --let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd
20 --let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd
21 --let t4_IBD = $MYSQLD_DATADIR/test/t4.ibd
22
23 create table t1(c1 bigint not null, b char(200)) engine=innodb encrypted=yes encryption_key_id=4;
24 show warnings;
25 create table t2(c1 bigint not null, b char(200)) engine=innodb page_compressed=1 encrypted=yes encryption_key_id=4;
26 show warnings;
27 let $kbs= `select floor(@@global.innodb_page_size/1024)`;
28 --replace_regex / key_block_size=\d+//i
29 eval create table t3(c1 bigint not null, b char(200)) engine=innodb row_format=compressed encrypted=yes encryption_key_id=4 key_block_size=$kbs;
30 show warnings;
31 create table t4(c1 bigint not null, b char(200)) engine=innodb page_compressed=1;
32 show warnings;
33
34 delimiter //;
35 create procedure innodb_insert_proc (repeat_count int)
36 begin
37 declare current_num int;
38 set current_num = 0;
39 while current_num < repeat_count do
40 insert into t1 values(current_num, repeat('foobar',30));
41 insert into t2 values(current_num, repeat('barfoo',30));
42 insert into t3 values(current_num, repeat('tmpres',30));
43 insert into t4 values(current_num, repeat('mysql',30));
44 set current_num = current_num + 1;
45 end while;
46 end//
47 delimiter ;//
48 commit;
49
50 set autocommit=0;
51 call innodb_insert_proc(2000);
52 commit;
53 set autocommit=1;
54
55 select count(*) from t1;
56 select count(*) from t2;
57 select count(*) from t3;
58 select count(*) from t4;
59
60 let MYSQLD_DATADIR =`SELECT @@datadir`;
61 FLUSH TABLE t1,t2,t3,t4 FOR EXPORT;
62 --echo # List before copying files
63 --list_files $MYSQLD_DATADIR/test
64 perl;
65 do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
66 ib_backup_tablespaces("test", "t1","t2","t3","t4");
67 EOF
68 --list_files $MYSQLD_DATADIR/test
69
70 UNLOCK TABLES;
71
72 ALTER TABLE t1 DISCARD TABLESPACE;
73 ALTER TABLE t2 DISCARD TABLESPACE;
74 ALTER TABLE t3 DISCARD TABLESPACE;
75 ALTER TABLE t4 DISCARD TABLESPACE;
76
77 perl;
78 do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
79 ib_discard_tablespaces("test", "t1","t2","t3","t4");
80 ib_restore_tablespaces("test", "t1","t2","t3","t4");
81 EOF
82
83 ALTER TABLE t1 IMPORT TABLESPACE;
84 SHOW CREATE TABLE t1;
85 SELECT COUNT(*) FROM t1;
86 ALTER TABLE t2 IMPORT TABLESPACE;
87 SHOW CREATE TABLE t2;
88 SELECT COUNT(*) FROM t2;
89 ALTER TABLE t3 IMPORT TABLESPACE;
90 --replace_regex / key_block_size=\d+//i
91 SHOW CREATE TABLE t3;
92 SELECT COUNT(*) FROM t3;
93 ALTER TABLE t4 IMPORT TABLESPACE;
94 SHOW CREATE TABLE t4;
95 SELECT COUNT(*) FROM t4;
96
97 --echo # tables should be still either encrypted and/or compressed
98 --let SEARCH_PATTERN=foobar
99 --echo # t1 yes on expecting NOT FOUND
100 -- let SEARCH_FILE=$t1_IBD
101 -- source include/search_pattern_in_file.inc
102 --let SEARCH_PATTERN=barfoo
103 --echo # t2 yes on expecting NOT FOUND
104 -- let SEARCH_FILE=$t2_IBD
105 -- source include/search_pattern_in_file.inc
106 --let SEARCH_PATTERN=tmpres
107 --echo # t3 yes on expecting NOT FOUND
108 -- let SEARCH_FILE=$t3_IBD
109 -- source include/search_pattern_in_file.inc
110 --let SEARCH_PATTERN=mysql
111 --echo # t4 yes on expecting NOT FOUND
112 -- let SEARCH_FILE=$t4_IBD
113 -- source include/search_pattern_in_file.inc
114
115 DROP PROCEDURE innodb_insert_proc;
116 DROP TABLE t1,t2,t3,t4;
117
118 # reset system
119 --disable_query_log
120 eval SET GLOBAL innodb_compression_algorithm = $innodb_compression_algo;
121 --enable_query_log