-- source include/have_innodb.inc -- source include/have_example_key_management_plugin.inc -- source include/not_valgrind.inc -- source include/not_embedded.inc -- source include/not_windows.inc call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); 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."); --let $MYSQLD_TMPDIR = `SELECT @@tmpdir` --let $MYSQLD_DATADIR = `SELECT @@datadir` --let SEARCH_RANGE = 10000000 --let $id = `SELECT RAND()` --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd --let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd --let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd --disable_query_log let $innodb_file_format_orig = `SELECT @@innodb_file_format`; let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`; --enable_query_log SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a VARCHAR(255)) ENGINE=InnoDB encrypted=yes; CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, a VARCHAR(255)) ENGINE=InnoDB; CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY, a VARCHAR(255)) ENGINE=InnoDB row_format=compressed encrypted=yes; delimiter //; create procedure innodb_insert_proc (repeat_count int) begin declare current_num int; set current_num = 0; while current_num < repeat_count do insert into t1 values (current_num,repeat('foobar',42)); insert into t2 values (current_num,repeat('temp', 42)); insert into t3 values (current_num,repeat('barfoo',42)); set current_num = current_num + 1; end while; end// delimiter ;// commit; set autocommit=0; call innodb_insert_proc(10000); commit; set autocommit=1; --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 --source include/wait_condition.inc --sleep 5 --echo # tablespaces should be now encrypted --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND -- let SEARCH_FILE=$t1_IBD -- source include/search_pattern_in_file.inc --let SEARCH_PATTERN=temp --echo # t2 ... on expecting NOT FOUND -- let SEARCH_FILE=$t2_IBD -- source include/search_pattern_in_file.inc --let SEARCH_PATTERN=barfoo --echo # t3 ... on expecting NOT FOUND -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc FLUSH TABLE t1, t2, t3 FOR EXPORT; --echo # List before copying files --list_files $MYSQLD_DATADIR/test --disable_result_log --error 0,1,2 --remove_file $MYSQLD_TMPDIR/t1.cfg --error 0,1,2 --remove_file $MYSQLD_TMPDIR/t1.ibd --error 0,1,2 --remove_file $MYSQLD_TMPDIR/t2.cfg --error 0,1,2 --remove_file $MYSQLD_TMPDIR/t2.ibd --error 0,1,2 --remove_file $MYSQLD_TMPDIR/t3.cfg --error 0,1,2 --remove_file $MYSQLD_TMPDIR/t3.ibd --enable_result_log --copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_TMPDIR/t1$id.cfg --copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_TMPDIR/t1$id.ibd --copy_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_TMPDIR/t2$id.cfg --copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_TMPDIR/t2$id.ibd --copy_file $MYSQLD_DATADIR/test/t3.cfg $MYSQLD_TMPDIR/t3$id.cfg --copy_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_TMPDIR/t3$id.ibd UNLOCK TABLES; --echo # Restarting server -- source include/restart_mysqld.inc --echo # Done restarting server --echo # List before t1 DISCARD --list_files $MYSQLD_DATADIR/test SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; ALTER TABLE t1 DISCARD TABLESPACE; ALTER TABLE t2 DISCARD TABLESPACE; ALTER TABLE t3 DISCARD TABLESPACE; --echo # List after t1 DISCARD --list_files $MYSQLD_DATADIR/test --disable_result_log --error 0,1,2 --remove_file $MYSQLD_DATADIR/test/t1.cfg --error 0,1,2 --remove_file $MYSQLD_DATADIR/test/t1.ibd --error 0,1,2 --remove_file $MYSQLD_DATADIR/test/t2.cfg --error 0,1,2 --remove_file $MYSQLD_DATADIR/test/t2.ibd --error 0,1,2 --remove_file $MYSQLD_DATADIR/test/t3.cfg --error 0,1,2 --remove_file $MYSQLD_DATADIR/test/t3.ibd --enable_result_log --echo # Restarting server -- source include/restart_mysqld.inc --echo # Done restarting server SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; --copy_file $MYSQLD_TMPDIR/t1$id.cfg $MYSQLD_DATADIR/test/t1.cfg --copy_file $MYSQLD_TMPDIR/t1$id.ibd $MYSQLD_DATADIR/test/t1.ibd --copy_file $MYSQLD_TMPDIR/t2$id.cfg $MYSQLD_DATADIR/test/t2.cfg --copy_file $MYSQLD_TMPDIR/t2$id.ibd $MYSQLD_DATADIR/test/t2.ibd --copy_file $MYSQLD_TMPDIR/t3$id.cfg $MYSQLD_DATADIR/test/t3.cfg --copy_file $MYSQLD_TMPDIR/t3$id.ibd $MYSQLD_DATADIR/test/t3.ibd --sleep 5 --echo # Tablespaces should be still encrypted --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND -- let SEARCH_FILE=$t1_IBD -- source include/search_pattern_in_file.inc --let SEARCH_PATTERN=temp --echo # t2 ... on expecting NOT FOUND -- let SEARCH_FILE=$t2_IBD -- source include/search_pattern_in_file.inc --echo # t3 ... on expecting NOT FOUND --let SEARCH_PATTERN=barfoo -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc ALTER TABLE t1 IMPORT TABLESPACE; SELECT COUNT(1) FROM t1; ALTER TABLE t2 IMPORT TABLESPACE; SELECT COUNT(1) FROM t2; ALTER TABLE t3 IMPORT TABLESPACE; SELECT COUNT(1) FROM t3; --sleep 5 --echo # tablespaces should remain encrypted after import --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND -- let SEARCH_FILE=$t1_IBD -- source include/search_pattern_in_file.inc --let SEARCH_PATTERN=temp --echo # t2 ... on expecting NOT FOUND -- let SEARCH_FILE=$t2_IBD -- source include/search_pattern_in_file.inc --echo # t3 ... on expecting NOT FOUND --let SEARCH_PATTERN=barfoo -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc ALTER TABLE t1 ENGINE InnoDB; SHOW CREATE TABLE t1; ALTER TABLE t2 ENGINE InnoDB; SHOW CREATE TABLE t2; ALTER TABLE t3 ENGINE InnoDB; SHOW CREATE TABLE t3; --echo # Wait max 10 min for key encryption threads to encrypt all spaces --let $wait_timeout= 600 --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 --source include/wait_condition.inc --sleep 5 --echo # Tablespaces should be encrypted after alter table --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND -- let SEARCH_FILE=$t1_IBD -- source include/search_pattern_in_file.inc --let SEARCH_PATTERN=temp --echo # t2 ... on expecting NOT FOUND -- let SEARCH_FILE=$t2_IBD -- source include/search_pattern_in_file.inc --echo # t3 ... on expecting NOT FOUND --let SEARCH_PATTERN=barfoo -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc --echo # Restarting server -- source include/restart_mysqld.inc --echo # Done restarting server --echo # Verify that tables are still usable SELECT COUNT(1) FROM t1; SELECT COUNT(1) FROM t2; SELECT COUNT(1) FROM t3; --sleep 5 --echo # Tablespaces should be encrypted after restart --let SEARCH_PATTERN=foobar --echo # t1 yes on expecting NOT FOUND -- let SEARCH_FILE=$t1_IBD -- source include/search_pattern_in_file.inc --let SEARCH_PATTERN=temp --echo # t2 ... on expecting NOT FOUND -- let SEARCH_FILE=$t2_IBD -- source include/search_pattern_in_file.inc --echo # t3 ... on expecting NOT FOUND --let SEARCH_PATTERN=barfoo -- let SEARCH_FILE=$t3_IBD -- source include/search_pattern_in_file.inc DROP PROCEDURE innodb_insert_proc; DROP TABLE t1, t2, t3; # reset system --disable_query_log EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig; EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig; --enable_query_log