mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	The issue was a bad merge of MDEV-12253 from 10.1 to 10.2
in commit f9cc391863.
In that merge, I wrongly assumed that all test file conflicts
for mysql-test/suite/encryption had been properly resolved in
bb-10.2-MDEV-12253 (commit 76aa6be77635c7017459ce33b41c837c9acb606d)
while in fact, some files there had been copied from the 10.1 branch.
This commit is based on a manually done conflict resolution of
the mysql-test/suite/encryption on the same merge, applied to
the current 10.2 branch.
As part of this commit, the test encryption.innodb-bad-key-change4
which was shortly disabled due to MDEV-11336 will be re-enabled again.
(While the test enables innodb_defragment, it does not fail even though
enabling innodb_defragment currently has no effect.)
		
	
		
			
				
	
	
		
			142 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
-- source include/have_innodb.inc
 | 
						|
-- source include/have_example_key_management_plugin.inc
 | 
						|
-- source include/not_valgrind.inc
 | 
						|
-- source include/not_embedded.inc
 | 
						|
 | 
						|
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
 | 
						|
 | 
						|
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
 | 
						|
 | 
						|
--list_files $MYSQLD_DATADIR/test
 | 
						|
FLUSH TABLES t1, t2, t3 FOR EXPORT;
 | 
						|
perl;
 | 
						|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
 | 
						|
ib_backup_tablespaces("test", "t1","t2","t3");
 | 
						|
EOF
 | 
						|
--list_files $MYSQLD_DATADIR/test
 | 
						|
UNLOCK TABLES;
 | 
						|
 | 
						|
ALTER TABLE t1 DISCARD TABLESPACE;
 | 
						|
ALTER TABLE t2 DISCARD TABLESPACE;
 | 
						|
ALTER TABLE t3 DISCARD TABLESPACE;
 | 
						|
 | 
						|
perl;
 | 
						|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
 | 
						|
ib_discard_tablespaces("test", "t1","t2","t3");
 | 
						|
ib_restore_tablespaces("test", "t1","t2","t3");
 | 
						|
EOF
 | 
						|
 | 
						|
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 # 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
 | 
						|
 | 
						|
--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
 | 
						|
 | 
						|
--echo # Success!
 | 
						|
--echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
 | 
						|
-- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0
 | 
						|
-- source include/restart_mysqld.inc
 | 
						|
 | 
						|
DROP PROCEDURE innodb_insert_proc;
 | 
						|
DROP TABLE t1, t2, t3;
 |