# restart: --no-console --log-error=ERROR_LOG_FILE
SELECT @@global.innodb_redo_log_encrypt ;
@@global.innodb_redo_log_encrypt
OFF
SET GLOBAL innodb_redo_log_encrypt = MASTER_KEY;
Warnings:
Warning	11008	InnoDB: Redo log cannot be encrypted if the keyring plugin is not loaded.
UNINSTALL PLUGIN keyring_file;
ERROR 42000: PLUGIN keyring_file does not exist
CREATE TABLE tne_1(c1 INT, c2 varchar(2000)) ENGINE = InnoDB;
INSERT INTO tne_1 VALUES (1,REPEAT('a',1990)),(2,REPEAT('b',1990)),(100,REPEAT('c',1990));
SELECT c1,LEFT(c2,10) FROM tne_1;
c1	LEFT(c2,10)
1	aaaaaaaaaa
2	bbbbbbbbbb
100	cccccccccc
DROP TABLE tne_1;
# Stop the MTR default DB server
Pattern "Redo log cannot be encrypted if the keyring plugin is not loaded." not found
# create bootstrap file
# Prepare new datadir
# Run the bootstrap command with keyring
# Starting server with keyring plugin
SELECT @@global.innodb_redo_log_encrypt;
@@global.innodb_redo_log_encrypt
OFF
SET GLOBAL innodb_redo_log_encrypt = MASTER_KEY;
INSTALL PLUGIN keyring_file SONAME 'keyring_file.so';
ERROR HY000: Function 'keyring_file' already exists
SET GLOBAL innodb_redo_log_encrypt = 0;
SELECT @@global.innodb_redo_log_encrypt;
@@global.innodb_redo_log_encrypt
OFF
INSTALL PLUGIN keyring_file SONAME 'keyring_file.so';
ERROR HY000: Function 'keyring_file' already exists
CREATE DATABASE tde_db;
USE tde_db;
CREATE TABLE tde_db.t_encrypt(c2 INT NOT NULL PRIMARY KEY,
c3 LONGBLOB
) ENCRYPTION="Y"  ENGINE = InnoDB;
CREATE TABLE tde_db.t_non_encrypt(c2 INT NOT NULL PRIMARY KEY,
c3 LONGBLOB
) ENGINE = InnoDB;
CREATE PROCEDURE tde_db.populate_table_set_redo_encrypt(IN table_name VARCHAR(50))
BEGIN
declare i int default 1;
declare has_error int default 0;
DECLARE CONTINUE HANDLER FOR 1062 SET has_error = 1;
while (i <= 2000) DO
SET @sql_text = CONCAT('INSERT INTO ',table_name, '(c2,c3) VALUES (' , i,',' ,'CONCAT(REPEAT("a",6*512*512)))');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
set i = i + 1;
IF i%10 = 0 THEN SET GLOBAL innodb_redo_log_encrypt = MASTER_KEY;
END IF;
IF i%20 = 0 THEN SET GLOBAL innodb_redo_log_encrypt = 0;
END IF;
end while;
end|
CREATE PROCEDURE tde_db.update_table(IN table_name VARCHAR(50))
BEGIN
declare i int default 1;
declare has_error int default 0;
DECLARE CONTINUE HANDLER FOR 1062 SET has_error = 1;
while (i <= 2000) DO
SET @sql_text = CONCAT('UPDATE ',table_name,  ' SET c2 = c2 * -1 ORDER BY RAND() LIMIT 2');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
set i = i + 1;
end while;
END|
CREATE PROCEDURE tde_db.delete_table(IN table_name VARCHAR(50))
BEGIN
declare i int default 1;
declare has_error int default 0;
DECLARE CONTINUE HANDLER FOR 1062 SET has_error = 1;
while (i <= 2000) DO
SET @sql_text = CONCAT('DELETE FROM  ',table_name,  '  ORDER BY RAND() LIMIT 2');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
set i = i + 1;
end while;
END|
CREATE PROCEDURE tde_db.transaction_table(IN table_name VARCHAR(50))
BEGIN
declare i int default 1;
declare iflag int default -1;
declare has_error int default 0;
DECLARE CONTINUE HANDLER FOR 1062 SET has_error = 1;
SET i = 3000;
START TRANSACTION;
while (i <= 9000) DO
SET @sql_text = CONCAT('INSERT INTO ',table_name, '(c2,c3) VALUES (' , i,',' ,'CONCAT(REPEAT("a",6*512*512)))');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
SET @sql_text = CONCAT('UPDATE ',table_name,  ' SET c2 = c2 * -1 ORDER BY RAND() LIMIT 2');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
set i = i + 1;
IF i%10 = 0 THEN SET GLOBAL innodb_redo_log_encrypt = MASTER_KEY;
END IF;
IF i%20 = 0 THEN SET GLOBAL innodb_redo_log_encrypt = 0;
END IF;
IF i%10 = 0 THEN
SET @sql_text = CONCAT('DELETE FROM  ',table_name,  '  ORDER BY RAND() LIMIT 2');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
START TRANSACTION;
SET iflag = -1 * iflag;
END IF;
IF i%9 = 0 THEN
IF iflag < 0 THEN
COMMIT;
ELSE
ROLLBACK;
END IF;
END IF;
end while;
END|
CREATE PROCEDURE tde_db.create_table_rotate_key()
BEGIN
declare i int default 1;
declare has_error int default 0;
DECLARE CONTINUE HANDLER FOR 1062 SET has_error = 1;
while (i <= 2000) DO
IF i%10 = 0 THEN
SET @sql_text = CONCAT('CREATE TABLE ',CONCAT('tde_db.t_non_encrypt_',encrypt,'_',i),' (c1 INT) ' ,' ENGINE=InnoDB');
ELSE
SET @sql_text = CONCAT('CREATE TABLE ',CONCAT('tde_db.t_encrypt_',encrypt,'_',i),' (c1 INT) ENCRYPTION="Y"' ,' ENGINE=InnoDB');
END IF;
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
ALTER INSTANCE ROTATE INNODB MASTER KEY;
set i = i + 1;
end while;
END|
CREATE PROCEDURE tde_db.query_table(IN table_name VARCHAR(50))
BEGIN
declare i int default 1;
declare has_error int default 0;
DECLARE CONTINUE HANDLER FOR 1062 SET has_error = 1;
while (i <= 2000) DO
SET @sql_text = CONCAT('SELECT * FROM ',table_name,  '  ORDER BY RAND() LIMIT 2');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
set i = i + 1;
end while;
END|
# In connection con1 - Running insert with redo_log_encrypt variable
call tde_db.populate_table_set_redo_encrypt('tde_db.t_encrypt');
# In connection con2 - Running insert on non encrypt table
call tde_db.populate_table_set_redo_encrypt('tde_db.t_non_encrypt');
# Starting server with keyring plugin
# Kill and restart:<hidden args>
SELECT COUNT(*)>0  FROM tde_db.t_encrypt;
COUNT(*)>0
#
SELECT COUNT(*)>0  FROM tde_db.t_non_encrypt;
COUNT(*)>0
#
DELETE FROM tde_db.t_encrypt;
DELETE FROM tde_db.t_non_encrypt;
# In connection con1 - Running insert with redo_log_encrypt variable
call tde_db.populate_table_set_redo_encrypt('tde_db.t_encrypt');
# In connection con2 - Running insert on non encrypt table
call tde_db.populate_table_set_redo_encrypt('tde_db.t_non_encrypt');
# In connection con3 - Running update on encrypt
call tde_db.table_update('tde_db.t_encrypt');
# In connection con4 - Running update non encrypt
call tde_db.table_update('tde_db.t_non_encrypt');
# In connection con5 - Running delete on encrypt
call tde_db.table_delete('tde_db.t_encrypt');
# In connection con6 - Running delete on non encrypt
call tde_db.table_delete('tde_db.t_non_encrypt');
# In connection con7 - Running transaction on  encrypt
call tde_db.transaction_table('tde_db.t_encrypt');
# In connection con8 - Running transaction on non encrypt
call tde_db.transaction_table('tde_db.t_non_encrypt');
# In connection con9 - Running create encrypt and non encrypt table with rotate key
call tde_db.create_table_rotate_key();
# In connection con10 - Running query on encrypt table
call tde_db.query_table('tde_db.t_encrypt');
# In connection con11 - Running query on non encrypt table
call tde_db.query_table('tde_db.t_non_encrypt');
# Starting server with keyring plugin
# Kill and restart:<hidden args>
SELECT COUNT(*) > 1 FROM tde_db.t_encrypt;
COUNT(*) > 1
#
SELECT COUNT(*) > 1 FROM tde_db.t_non_encrypt;
COUNT(*) > 1
#
# In connection con1 - Running insert with redo_log_encrypt variable
call tde_db.populate_table_set_redo_encrypt('tde_db.t_encrypt');
# In connection con2 - Running insert on non encrypt table
call tde_db.populate_table_set_redo_encrypt('tde_db.t_non_encrypt');
DROP DATABASE tde_db;
# restart
#
# Cleanup
#
