Debian Codegraph @

mysql-test/suite/encryption/t/innodb-bad-key-change3.test

raw
1 --source include/have_innodb.inc
2 # embedded does not support restart
3 -- source include/not_embedded.inc
4 -- source include/not_valgrind.inc
5 # Avoid CrashReporter popup on Mac
6 -- source include/not_crashrep.inc
7 -- source filekeys_plugin_exists.inc
8 #
9 # MDEV-8772: Assertion failure in file ha_innodb.cc line 20027 when importing page compressed and encrypted tablespace using incorrect keys
10 #
11
12 call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded.");
13 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.");
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 --write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
20 --shutdown_server
21 --source include/wait_until_disconnected.inc
22
23 --write_file $MYSQLTEST_VARDIR/keys1.txt
24 1;770A8A65DA156D24EE2A093277530142
25 4;770A8A65DA156D24EE2A093277530143
26 EOF
27
28 --write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
29 --enable_reconnect
30 --source include/wait_until_connected_again.inc
31
32 set global innodb_compression_algorithm = 1;
33
34 CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(255)) ENGINE=InnoDB PAGE_COMPRESSED=1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
35 SHOW WARNINGS;
36 SHOW CREATE TABLE t1;
37 INSERT INTO t1 VALUES (1,'foobar'),(2,'barfoo');
38 let MYSQLD_DATADIR =`SELECT @@datadir`;
39 FLUSH TABLE t1 FOR EXPORT;
40 --echo # List before copying files
41 --list_files $MYSQLD_DATADIR/test
42 perl;
43 do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
44 ib_backup_tablespaces("test", "t1");
45 EOF
46 UNLOCK TABLES;
47
48 ALTER TABLE t1 DISCARD TABLESPACE;
49
50 --write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
51 --shutdown_server
52 --source include/wait_until_disconnected.inc
53
54 --write_file $MYSQLTEST_VARDIR/keys2.txt
55 1;770A8A65DA156D24EE2A093277530142
56 4;770A8A65DA156D24EE2A093277530144
57 EOF
58
59 perl;
60 do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
61 ib_discard_tablespaces("test", "t1");
62 ib_restore_tablespaces("test", "t1");
63 EOF
64
65 --write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
66 --enable_reconnect
67 --source include/wait_until_connected_again.inc
68 --source include/restart_mysqld.inc
69
70 --error ER_GET_ERRMSG
71 ALTER TABLE t1 IMPORT TABLESPACE;
72 SHOW CREATE TABLE t1;
73 --error ER_TABLESPACE_DISCARDED
74 SELECT * FROM t1;
75 --sleep 5
76 --echo # Tablespaces should be still encrypted
77 -- let SEARCH_FILE=$t1_IBD
78 --let SEARCH_PATTERN=foobar
79 --echo # t1 yes on expecting NOT FOUND
80 -- let SEARCH_FILE=$t1_IBD
81 -- source include/search_pattern_in_file.inc
82
83 --write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
84 --shutdown_server
85 --source include/wait_until_disconnected.inc
86 --remove_file $MYSQLTEST_VARDIR/keys1.txt
87 --write_file $MYSQLTEST_VARDIR/keys1.txt
88 1;770A8A65DA156D24EE2A093277530142
89 4;770A8A65DA156D24EE2A093277530143
90 EOF
91
92 --write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
93 --enable_reconnect
94 --source include/wait_until_connected_again.inc
95 DROP TABLE t1;
96
97 # reset system
98
99 --remove_file $MYSQLTEST_VARDIR/keys1.txt
100 --remove_file $MYSQLTEST_VARDIR/keys2.txt