|
| 1 | +-- source include/have_innodb.inc |
| 2 | +-- source include/not_embedded.inc |
| 3 | +-- source include/have_example_key_management_plugin.inc |
| 4 | + |
| 5 | +CREATE TABLE t1 (f1 INT, f2 VARCHAR(256))engine=innodb; |
| 6 | +INSERT INTO t1 VALUES(1, 'MariaDB'), (2, 'Robot'), (3, 'Science'); |
| 7 | +INSERT INTO t1 SELECT * FROM t1; |
| 8 | + |
| 9 | +CREATE TABLE t2(f1 INT, f2 VARCHAR(256))engine=innodb; |
| 10 | +INSERT INTO t2 SELECT * FROM t1; |
| 11 | + |
| 12 | +CREATE TABLE t3(f1 INT, f2 VARCHAR(256))engine=innodb encrypted=yes; |
| 13 | +INSERT INTO t3 SELECT * FROM t1; |
| 14 | + |
| 15 | +--echo # Restart the server with encryption |
| 16 | + |
| 17 | +let $restart_parameters= --innodb_encryption_threads=5 --innodb_encryption_rotate_key_age=16384; |
| 18 | +--source include/restart_mysqld.inc |
| 19 | + |
| 20 | +--echo # Wait until encryption threads have encrypted all tablespaces |
| 21 | + |
| 22 | +--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'` |
| 23 | +--let $wait_timeout= 600 |
| 24 | +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 25 | +--source include/wait_condition.inc |
| 26 | + |
| 27 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 28 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 29 | + |
| 30 | +--echo # Restart the server with innodb_encryption_rotate_key_age= 0 |
| 31 | + |
| 32 | +let $restart_parameters= --innodb_encryption_threads=1 --innodb_encryption_rotate_key_age=0; |
| 33 | + |
| 34 | +--source include/restart_mysqld.inc |
| 35 | + |
| 36 | +create table t4 (f1 int not null)engine=innodb encrypted=NO; |
| 37 | + |
| 38 | +--echo # Wait until encryption threads have encrypted all tablespaces |
| 39 | + |
| 40 | +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` |
| 41 | +--let $wait_timeout= 600 |
| 42 | +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 43 | +--source include/wait_condition.inc |
| 44 | + |
| 45 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 46 | + |
| 47 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 48 | + |
| 49 | +--echo # Disable encryption when innodb_encryption_rotate_key_age is 0 |
| 50 | +set global innodb_encrypt_tables = OFF; |
| 51 | + |
| 52 | +--echo # Wait until encryption threads to decrypt all unencrypted tablespaces |
| 53 | + |
| 54 | +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` |
| 55 | +--let $wait_timeout= 600 |
| 56 | +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0; |
| 57 | +--source include/wait_condition.inc |
| 58 | + |
| 59 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 60 | +--echo # Display only encrypted create tables (t3) |
| 61 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 62 | + |
| 63 | +--echo # Enable encryption when innodb_encryption_rotate_key_age is 0 |
| 64 | +set global innodb_encrypt_tables = ON; |
| 65 | + |
| 66 | +--echo # Wait until encryption threads to encrypt all unencrypted tablespaces |
| 67 | + |
| 68 | +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` |
| 69 | +--let $wait_timeout= 600 |
| 70 | +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 71 | +--source include/wait_condition.inc |
| 72 | + |
| 73 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 74 | +--echo # Display only unencrypted create tables (t4) |
| 75 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 76 | + |
| 77 | +--let $restart_parameters= |
| 78 | +-- source include/restart_mysqld.inc |
| 79 | + |
| 80 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; |
| 81 | +SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; |
| 82 | +DROP TABLE t4, t3, t2, t1; |
0 commit comments