1-- source include/have_innodb.inc
2-- source include/not_embedded.inc
3-- source include/have_file_key_management_plugin.inc
4
5create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb;
6show warnings;
7create table innodb_compact(c1 bigint not null, b char(200)) engine=innodb row_format=compact encrypted=yes encryption_key_id=1;
8show warnings;
9create table innodb_compressed(c1 bigint not null, b char(200)) engine=innodb row_format=compressed encrypted=yes encryption_key_id=2;
10show warnings;
11create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic encrypted=yes  encryption_key_id=33;
12show warnings;
13create table innodb_redundant(c1 bigint not null, b char(200))  engine=innodb row_format=redundant encrypted=yes  encryption_key_id=4;
14show warnings;
15
16show create table innodb_compact;
17show create table innodb_compressed;
18show create table innodb_dynamic;
19show create table innodb_redundant;
20
21FLUSH TABLES innodb_normal FOR EXPORT; UNLOCK TABLES;
22FLUSH TABLES innodb_compact FOR EXPORT; UNLOCK TABLES;
23FLUSH TABLES innodb_compressed FOR EXPORT; UNLOCK TABLES;
24FLUSH TABLES innodb_dynamic FOR EXPORT; UNLOCK TABLES;
25FLUSH TABLES innodb_redundant FOR EXPORT; UNLOCK TABLES;
26
27select variable_value > 0 from information_schema.global_status
28where variable_name = 'INNODB_NUM_PAGES_ENCRYPTED';
29
30--source include/restart_mysqld.inc
31
32BEGIN;
33INSERT INTO innodb_normal SET c1 = 1;
34INSERT INTO innodb_compact SET c1 = 1;
35INSERT INTO innodb_compressed SET c1 = 1;
36INSERT INTO innodb_dynamic SET c1 = 1;
37INSERT INTO innodb_redundant SET c1 = 1;
38COMMIT;
39
40FLUSH TABLES innodb_normal FOR EXPORT; UNLOCK TABLES;
41FLUSH TABLES innodb_compact FOR EXPORT; UNLOCK TABLES;
42FLUSH TABLES innodb_compressed FOR EXPORT; UNLOCK TABLES;
43FLUSH TABLES innodb_dynamic FOR EXPORT; UNLOCK TABLES;
44FLUSH TABLES innodb_redundant FOR EXPORT; UNLOCK TABLES;
45
46select variable_name from information_schema.global_status
47where variable_value > 0 and variable_name
48IN ('INNODB_NUM_PAGES_ENCRYPTED','INNODB_NUM_PAGES_DECRYPTED');
49
50SET GLOBAL innodb_encrypt_tables=OFF;
51alter table innodb_compact engine=innodb encrypted=DEFAULT encryption_key_id=DEFAULT;
52show create table innodb_compact;
53alter table innodb_compressed engine=innodb encrypted=DEFAULT encryption_key_id=DEFAULT;
54show create table innodb_compressed;
55alter table innodb_dynamic engine=innodb encrypted=DEFAULT encryption_key_id=DEFAULT;
56show create table innodb_dynamic;
57alter table innodb_redundant engine=innodb encrypted=DEFAULT encryption_key_id=DEFAULT;
58show create table innodb_redundant;
59
60FLUSH TABLES innodb_normal FOR EXPORT; UNLOCK TABLES;
61FLUSH TABLES innodb_compact FOR EXPORT; UNLOCK TABLES;
62FLUSH TABLES innodb_compressed FOR EXPORT; UNLOCK TABLES;
63FLUSH TABLES innodb_dynamic FOR EXPORT; UNLOCK TABLES;
64FLUSH TABLES innodb_redundant FOR EXPORT; UNLOCK TABLES;
65
66drop table innodb_normal;
67drop table innodb_compact;
68drop table innodb_compressed;
69drop table innodb_dynamic;
70drop table innodb_redundant;
71#
72# MDEV-8143: InnoDB: Database page corruption on disk or a failed file read
73#
74CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB ENCRYPTION_KEY_ID=2 ENCRYPTED=YES;
75INSERT INTO t1 VALUES (1),(2);
76
77--echo # Restarting server...
78--source include/restart_mysqld.inc
79
80SELECT * FROM t1;
81
82DROP TABLE t1;
83