| 1 |
-- source include/have_innodb.inc |
| 2 |
-- source include/have_file_key_management_plugin.inc |
| 3 |
# |
| 4 |
# MDEV-11656: 'Data structure corruption' IMPORT TABLESPACE doesn't work for encrypted InnoDB tables if space_id changed |
| 5 |
# |
| 6 |
|
| 7 |
call mtr.add_suppression("InnoDB: Table .* tablespace is set as discarded"); |
| 8 |
|
| 9 |
let $innodb_compression_algo = `SELECT @@innodb_compression_algorithm`; |
| 10 |
|
| 11 |
SET GLOBAL innodb_compression_algorithm = 1; |
| 12 |
|
| 13 |
create table t1(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb encrypted=yes encryption_key_id=4; |
| 14 |
create table t2(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb encrypted=yes encryption_key_id=1; |
| 15 |
create table t3(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb page_compressed=yes; |
| 16 |
create table t4(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb page_compressed=yes encrypted=yes encryption_key_id=4; |
| 17 |
create table t5(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb; |
| 18 |
|
| 19 |
insert into t1 values (NULL, 'verysecretmessage'); |
| 20 |
insert into t1(b) select b from t1; |
| 21 |
insert into t1(b) select b from t1; |
| 22 |
insert into t1(b) select b from t1; |
| 23 |
insert into t1(b) select b from t1; |
| 24 |
insert into t1(b) select b from t1; |
| 25 |
insert into t1(b) select b from t1; |
| 26 |
insert into t1(b) select b from t1; |
| 27 |
insert into t1(b) select b from t1; |
| 28 |
insert into t2 select * from t1; |
| 29 |
insert into t3 select * from t1; |
| 30 |
insert into t4 select * from t1; |
| 31 |
insert into t5 select * from t1; |
| 32 |
|
| 33 |
let MYSQLD_DATADIR =`SELECT @@datadir`; |
| 34 |
FLUSH TABLE t1,t2,t3,t4,t5 FOR EXPORT; |
| 35 |
perl; |
| 36 |
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; |
| 37 |
ib_backup_tablespaces("test", "t1","t2","t3","t4","t5"); |
| 38 |
EOF |
| 39 |
--list_files $MYSQLD_DATADIR/test |
| 40 |
UNLOCK TABLES; |
| 41 |
|
| 42 |
ALTER TABLE t1 DISCARD TABLESPACE; |
| 43 |
ALTER TABLE t2 DISCARD TABLESPACE; |
| 44 |
ALTER TABLE t3 DISCARD TABLESPACE; |
| 45 |
ALTER TABLE t4 DISCARD TABLESPACE; |
| 46 |
ALTER TABLE t5 DISCARD TABLESPACE; |
| 47 |
|
| 48 |
# |
| 49 |
# Now intentionally change space_id for t1,t3,t4,t5 |
| 50 |
# |
| 51 |
DROP TABLE t1; |
| 52 |
DROP TABLE t3; |
| 53 |
DROP TABLE t4; |
| 54 |
DROP TABLE t5; |
| 55 |
|
| 56 |
create table t6(a int) engine=innodb; |
| 57 |
create table t5(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb; |
| 58 |
create table t3(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb page_compressed=yes; |
| 59 |
create table t1(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb encrypted=yes encryption_key_id=4; |
| 60 |
create table t4(c1 bigint not null primary key auto_increment, b char(200)) engine=innodb page_compressed=yes encrypted=yes encryption_key_id=4; |
| 61 |
|
| 62 |
ALTER TABLE t1 DISCARD TABLESPACE; |
| 63 |
ALTER TABLE t3 DISCARD TABLESPACE; |
| 64 |
ALTER TABLE t4 DISCARD TABLESPACE; |
| 65 |
ALTER TABLE t5 DISCARD TABLESPACE; |
| 66 |
|
| 67 |
perl; |
| 68 |
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; |
| 69 |
ib_discard_tablespaces("test", "t1","t2","t3","t4","t5"); |
| 70 |
ib_restore_tablespaces("test", "t1","t2","t3","t4","t5"); |
| 71 |
EOF |
| 72 |
|
| 73 |
ALTER TABLE t1 IMPORT TABLESPACE; |
| 74 |
SHOW CREATE TABLE t1; |
| 75 |
SELECT COUNT(*) FROM t1; |
| 76 |
ALTER TABLE t2 IMPORT TABLESPACE; |
| 77 |
SELECT COUNT(*) FROM t2; |
| 78 |
ALTER TABLE t3 IMPORT TABLESPACE; |
| 79 |
SELECT COUNT(*) FROM t3; |
| 80 |
ALTER TABLE t4 IMPORT TABLESPACE; |
| 81 |
SELECT COUNT(*) FROM t4; |
| 82 |
ALTER TABLE t5 IMPORT TABLESPACE; |
| 83 |
SELECT COUNT(*) FROM t5; |
| 84 |
|
| 85 |
# |
| 86 |
# Verify |
| 87 |
# |
| 88 |
--let $MYSQLD_TMPDIR = `SELECT @@tmpdir` |
| 89 |
--let $MYSQLD_DATADIR = `SELECT @@datadir` |
| 90 |
--let SEARCH_RANGE = 10000000 |
| 91 |
--let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd |
| 92 |
--let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd |
| 93 |
--let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd |
| 94 |
--let t4_IBD = $MYSQLD_DATADIR/test/t4.ibd |
| 95 |
--let t5_IBD = $MYSQLD_DATADIR/test/t5.ibd |
| 96 |
--let SEARCH_PATTERN=verysecretmessage |
| 97 |
--echo # t1 encrypted expecting NOT FOUND |
| 98 |
-- let SEARCH_FILE=$t1_IBD |
| 99 |
-- source include/search_pattern_in_file.inc |
| 100 |
--echo # t2 encrypted expecting NOT FOUND |
| 101 |
-- let SEARCH_FILE=$t2_IBD |
| 102 |
-- source include/search_pattern_in_file.inc |
| 103 |
--echo # t3 page compressed expecting NOT FOUND |
| 104 |
-- let SEARCH_FILE=$t3_IBD |
| 105 |
-- source include/search_pattern_in_file.inc |
| 106 |
--echo # t4 page compressed and encrypted expecting NOT FOUND |
| 107 |
-- let SEARCH_FILE=$t4_IBD |
| 108 |
-- source include/search_pattern_in_file.inc |
| 109 |
--echo # t5 normal expecting FOUND |
| 110 |
-- let SEARCH_FILE=$t5_IBD |
| 111 |
-- source include/search_pattern_in_file.inc |
| 112 |
|
| 113 |
DROP TABLE t1,t2,t3,t4,t5,t6; |
| 114 |
|
| 115 |
# reset system |
| 116 |
--disable_query_log |
| 117 |
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algo; |
| 118 |
--enable_query_log |