Debian Codegraph @

mysql-test/suite/encryption/t/innodb-encryption-alter.test

raw
1 -- source include/have_innodb.inc
2 -- source include/have_debug.inc
3 -- source include/have_debug_sync.inc
4 -- source include/have_file_key_management_plugin.inc
5
6 #
7 # MDEV-8817: Failing assertion: new_state->key_version != ENCRYPTION_KEY_VERSION_INVALID
8 #
9
10 SET GLOBAL innodb_encrypt_tables = ON;
11 SET GLOBAL innodb_encryption_threads = 4;
12
13 CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4;
14 DROP TABLE t1;
15 set @save_global = @@GLOBAL.innodb_default_encryption_key_id;
16 set innodb_default_encryption_key_id = 99;
17 set global innodb_default_encryption_key_id = 99;
18 set global innodb_default_encryption_key_id = @save_global;
19 --error 1005
20 CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
21 SHOW WARNINGS;
22 --error 1005
23 CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=YES;
24 SHOW WARNINGS;
25 set innodb_default_encryption_key_id = 4;
26 CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=YES;
27 SHOW CREATE TABLE t1;
28 DROP TABLE t1;
29 CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
30 SHOW CREATE TABLE t1;
31 CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
32 --error ER_ILLEGAL_HA_CREATE_OPTION
33 ALTER TABLE t1 ENCRYPTION_KEY_ID=99;
34 SHOW WARNINGS;
35 set innodb_default_encryption_key_id = 1;
36
37
38 --disable_warnings
39 --disable_query_log
40 let $i = 400;
41 while ($i)
42 {
43 INSERT INTO t1 values(NULL, substring(MD5(RAND()), -128));
44 dec $i;
45 }
46 commit;
47 INSERT INTO t2 select * from t1;
48
49 --disable_abort_on_error
50
51 --connect (con1,localhost,root,,test)
52 --connect (con2,localhost,root,,test)
53
54 let $i = 50;
55 while ($i)
56 {
57 connection con1;
58 send ALTER TABLE t1 ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
59 connection con2;
60 send ALTER TABLE t1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
61 connection default;
62 send ALTER TABLE t2 ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
63 connection con1;
64 --reap;
65 ALTER TABLE t1 ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
66 connection con2;
67 --reap
68 ALTER TABLE t1 ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
69 connection default;
70 --reap
71 ALTER TABLE t2 ENCRYPTED=YES ENCRYPTION_KEY_ID=1;
72 ALTER TABLE t1 ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
73 dec $i;
74 }
75
76 connection default;
77 --disconnect con1
78 --disconnect con2
79
80 --enable_abort_on_error
81 --enable_warnings
82 --enable_query_log
83
84 drop table t1,t2;
85
86 #
87 # MDEV-17230: encryption_key_id from alter is ignored by encryption threads
88 #
89 --enable_warnings
90 SET GLOBAL innodb_encrypt_tables=OFF;
91 CREATE TABLE t1 (a int not null primary key) engine=innodb;
92 ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
93 SHOW CREATE TABLE t1;
94 DROP TABLE t1;
95
96 CREATE TABLE t2 (a int not null primary key) engine=innodb;
97 ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
98 SHOW WARNINGS;
99 SHOW CREATE TABLE t2;
100
101 CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
102 DROP TABLE t3;
103
104 SET GLOBAL innodb_encrypt_tables='FORCE';
105 --error ER_CANT_CREATE_TABLE
106 CREATE TABLE t1 (a int primary key) engine=innodb encrypted=no;
107 SHOW WARNINGS;
108
109 FLUSH TABLES;
110
111 create table t1(f1 int not null, f2 int not null)engine=innodb encrypted=yes;
112 insert into t1 values(1, 2), (2, 3), (4, 5), (5, 6), (7, 8);
113 insert into t1 select * from t1;
114 BEGIN;
115 INSERT INTO t2 VALUES (1);
116
117 connect con1, localhost, root;
118 SET DEBUG_SYNC = 'row_log_table_apply2_before SIGNAL done WAIT_FOR ever';
119 send alter table t1 force;
120
121 connection default;
122 SET DEBUG_SYNC = 'now WAIT_FOR done';
123 SET GLOBAL innodb_flush_log_at_trx_commit=1;
124 COMMIT;
125
126 let $restart_parameters = --innodb_encryption_threads=2;
127 let $restart_noprint = 2;
128 --let $shutdown_timeout= 0
129 --source include/restart_mysqld.inc
130 disconnect con1;
131
132 select * from t1;
133 drop table t1,t2;