summaryrefslogtreecommitdiff
path: root/mysql-test/suite/encryption/t/innodb-rowlog.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/encryption/t/innodb-rowlog.test')
-rw-r--r--mysql-test/suite/encryption/t/innodb-rowlog.test90
1 files changed, 90 insertions, 0 deletions
diff --git a/mysql-test/suite/encryption/t/innodb-rowlog.test b/mysql-test/suite/encryption/t/innodb-rowlog.test
new file mode 100644
index 00000000000..135293ef4b9
--- /dev/null
+++ b/mysql-test/suite/encryption/t/innodb-rowlog.test
@@ -0,0 +1,90 @@
+-- source include/have_innodb.inc
+-- source include/have_example_key_management_plugin.inc
+# needs dbug_dbug
+-- source include/have_debug.inc
+
+--disable_warnings
+--disable_query_log
+let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
+let $key_age = `SELECT @@innodb_encryption_rotate_key_age`;
+--enable_query_log
+
+SET GLOBAL innodb_file_format = `Barracuda`;
+--enable_warnings
+
+let $MYSQLD_DATADIR = `SELECT @@datadir`;
+let $MYSQLD_TMPDIR = `SELECT @@tmpdir`;
+
+#
+# Create a table that will be encrypted and put some sensitive data to it (credit card numbers)
+#
+
+create table t1(id int not null primary key auto_increment, credit_card varchar(200), private varchar(50)) engine=innodb;
+
+let $rows = 15000;
+--disable_query_log
+begin;
+while ($rows)
+{
+ eval insert into t1 values(NULL, '0000-0000-0000-0000','private_data');
+ dec $rows;
+}
+commit;
+--enable_query_log
+
+--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
+
+#
+# Now we create secondary index for credit_card column in parallel we create new rows
+# forcing alter table to wait so that row log is used.
+#
+SET SESSION debug_dbug="+d,ib_merge_wait_after_read";
+send alter table t1 add index secret (credit_card), ALGORITHM=INPLACE, LOCK=NONE;
+#
+# Force key rotation and create second index for same table
+#
+connect (con2,localhost,root,,);
+SET GLOBAL innodb_encryption_rotate_key_age = 1;
+create table t2(id int) engine=innodb;
+SET SESSION debug_dbug="+d,ib_merge_wait_after_read";
+send alter table t1 add index secret2 (private), ALGORITHM=INPLACE, LOCK=NONE;
+#
+# Create new rows to row log
+#
+connect (con1,localhost,root,,);
+insert into t1(credit_card) select credit_card from t1;
+insert into t1(credit_card) select credit_card from t1;
+insert into t1(credit_card) select credit_card from t1;
+
+connection default;
+reap;
+disconnect con1;
+
+connection con2;
+reap;
+drop table t2;
+
+connection default;
+disconnect con2;
+
+let $wait_condition= select variable_value > 0 from information_schema.global_status where variable_name = 'INNODB_NUM_PAGES_ENCRYPTED';
+--source include/wait_condition.inc
+
+#
+# Verify that both merge blocks and row log blocks are encryted and decrypted
+#
+
+SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_num_pages_encrypted';
+SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_merge_blocks_encrypted';
+SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_merge_blocks_decrypted';
+SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_rowlog_blocks_encrypted';
+SELECT variable_value > 0 FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_rowlog_blocks_decrypted';
+
+drop table t1;
+
+--disable_warnings
+eval SET GLOBAL innodb_file_format=$innodb_file_format_orig;
+eval SET GLOBAL innodb_encryption_rotate_key_age=$key_age;
+--enable_warnings