Debian Codegraph @

mysql-test/suite/innodb/t/table_encrypt_2.test

raw
1 # InnoDB transparent tablespace data encryption
2 # This test case will test basic encryption support features.
3
4
5 --source include/no_valgrind_without_big.inc
6
7 call mtr.add_suppression("\\[Error\\] .*MY-\\d+.* Can't generate new master key for tablespace encryption, please check the keyring plugin is loaded.");
8 call mtr.add_suppression("\\[Error\\] .*MY-\\d+.* Encryption can't find master key, please check the keyring plugin is loaded.");
9 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Function 'keyring_file' already exists");
10 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Couldn't load plugin named 'keyring_file' with soname 'keyring_file.*'.");
11 call mtr.add_suppression("Plugin keyring_file reported");
12
13 --disable_warnings
14 DROP TABLE IF EXISTS t1;
15 --enable_warnings
16
17 let $innodb_file_per_table = `SELECT @@innodb_file_per_table`;
18
19 SET GLOBAL innodb_file_per_table = 1;
20 SELECT @@innodb_file_per_table;
21
22 # Create a table with encryption
23 CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB;
24
25 SHOW CREATE TABLE t1;
26 INSERT INTO t1 VALUES(0, "aaaaa");
27 INSERT INTO t1 VALUES(1, "bbbbb");
28 INSERT INTO t1 VALUES(2, "ccccc");
29 INSERT INTO t1 VALUES(3, "ddddd");
30 INSERT INTO t1 VALUES(4, "eeeee");
31 INSERT INTO t1 VALUES(5, "fffff");
32 INSERT INTO t1 VALUES(6, "ggggg");
33 INSERT INTO t1 VALUES(7, "hhhhh");
34 INSERT INTO t1 VALUES(8, "iiiii");
35 INSERT INTO t1 VALUES(9, "jjjjj");
36 INSERT INTO t1 select * from t1;
37 INSERT INTO t1 select * from t1;
38 INSERT INTO t1 select * from t1;
39 INSERT INTO t1 select * from t1;
40 INSERT INTO t1 select * from t1;
41 INSERT INTO t1 select * from t1;
42
43 SELECT * FROM t1 LIMIT 10;
44
45 # Restart to confirm the encryption info can be retrieved properly.
46 --let $restart_parameters= restart:
47 --source include/restart_mysqld.inc
48
49 SELECT * FROM t1 LIMIT 10;
50
51 # Key rotation.
52 ALTER INSTANCE ROTATE INNODB MASTER KEY;
53
54 DROP TABLE t1;
55
56 # Crash/recovery test.
57 CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB;
58
59 INSERT INTO t1 VALUES(0, "aaaaa");
60 INSERT INTO t1 VALUES(1, "bbbbb");
61 INSERT INTO t1 VALUES(2, "ccccc");
62 INSERT INTO t1 VALUES(3, "ddddd");
63 INSERT INTO t1 VALUES(4, "eeeee");
64 INSERT INTO t1 VALUES(5, "fffff");
65 INSERT INTO t1 VALUES(6, "ggggg");
66 INSERT INTO t1 VALUES(7, "hhhhh");
67 INSERT INTO t1 VALUES(8, "iiiii");
68 INSERT INTO t1 VALUES(9, "jjjjj");
69
70 # Restart to confirm the encryption info can be retrieved properly.
71 --source include/kill_and_restart_mysqld.inc
72
73 SELECT * FROM t1 LIMIT 10;
74 DROP TABLE t1;
75
76
77
78 let $restart_parameters = restart: --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring2 --general-log --log-output=FILE --general_log_file=$MYSQL_TMP_DIR/keyring_query_log $KEYRING_PLUGIN_OPT ;
79 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH
80 --replace_regex /\.dll/.so/
81 --source include/restart_mysqld.inc
82 #
83 # Check no effect of block_encryption_mode = 'aes-256-cbc' variable on table encryption
84 SET block_encryption_mode = 'aes-256-cbc';
85 # Test encryption .
86 --disable_warnings
87 DROP DATABASE IF EXISTS tde_db;
88 CREATE DATABASE tde_db;
89 CREATE TABLE tde_db.t1(c1 INT PRIMARY KEY, c2 char(50)) ENCRYPTION = 'Y' ENGINE = InnoDB;
90 --enable_warnings
91 #
92 INSERT INTO tde_db.t1 VALUES(0, 'abc');
93 INSERT INTO tde_db.t1 VALUES(1, 'xyz');
94 INSERT INTO tde_db.t1 VALUES(2, null);
95 INSERT INTO tde_db.t1 VALUES(3, null);
96 SELECT * FROM tde_db.t1 LIMIT 10;
97 ALTER INSTANCE ROTATE INNODB MASTER KEY;
98 SELECT * FROM tde_db.t1 LIMIT 10;
99 --echo # Mysqldump output
100 --exec $MYSQL_DUMP --compact --skip-comments --databases tde_db
101 --echo # Redirecting mysqlpump output to MYSQL_TMP_DIR/mysqlpump_encrypt.sql
102 --exec $MYSQL_PUMP --default-parallelism=1 --databases tde_db > $MYSQL_TMP_DIR/mysqlpump_encrypt.sql
103 DROP DATABASE tde_db;
104
105 --let SEARCH_FILE=$MYSQL_TMP_DIR/keyring_query_log
106 let SEARCH_PATTERN= ALTER INSTANCE ROTATE INNODB MASTER KEY;
107 --source include/search_pattern.inc
108
109 --echo # Loading tables from mysqlpump_encrypt.sql
110 --exec $MYSQL --skip-comments < $MYSQL_TMP_DIR/mysqlpump_encrypt.sql
111 SELECT * FROM tde_db.t1 LIMIT 10;
112 INSERT INTO tde_db.t1 VALUES(4, null);
113 SELECT * FROM tde_db.t1 LIMIT 10;
114 DROP DATABASE tde_db;
115 #
116
117
118 --echo #
119 --echo # Bug #26634507 CREATE_OPTIONS FLD IN INFORMATION_SCHEMA.TABLES NOT
120 --echo # FILLING PROPERLY.
121 --echo # The CREATE_OPTIONS field from I_S.TABLES should show the option
122 --echo # 'ENCRYPTION='.
123 --echo #
124
125 CREATE TABLE not_encrypted1 (col1 INT) ENCRYPTION='n';
126 CREATE TABLE not_encrypted2 (col1 INT) ENCRYPTION='N';
127 CREATE TABLE encrypted1 (col1 INT) ENCRYPTION='y';
128 CREATE TABLE encrypted2 (col1 INT) ENCRYPTION='Y';
129
130 SELECT TABLE_SCHEMA, TABLE_NAME, CREATE_OPTIONS
131 FROM INFORMATION_SCHEMA.TABLES
132 WHERE TABLE_NAME like '%encrypted%'
133 ORDER BY TABLE_NAME;
134
135 DROP TABLE encrypted1;
136 DROP TABLE not_encrypted1;
137 DROP TABLE encrypted2;
138 DROP TABLE not_encrypted2;
139
140
141 # Cleanup
142
143 --let $restart_parameters = restart:
144 --source include/restart_mysqld.inc
145
146 --remove_file $MYSQL_TMP_DIR/keyring_query_log
147 --remove_file $MYSQL_TMP_DIR/mysqlpump_encrypt.sql
148 eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table;