summaryrefslogtreecommitdiff
path: root/mysql-test/suite/encryption/t/create_or_replace.test
blob: 3b2970e5162806635ef4409494f1e4340be4c510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
--source include/have_innodb.inc
--source include/have_file_key_management_plugin.inc
--source include/not_embedded.inc
# This is needed for longer testcase timeout at least P7/P8
--source include/big_test.inc

#
# MDEV-8164: Server crashes in pfs_mutex_enter_func after fil_crypt_is_closing or alike
#
SET default_storage_engine = InnoDB;

CREATE TABLE t1 (pk INT PRIMARY KEY, c VARCHAR(256));
CREATE TABLE t2 AS SELECT * FROM t1;

--disable_abort_on_error
--disable_warnings
--disable_query_log

let $i = 40;
while ($i)
{
SET GLOBAL innodb_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 1;
CREATE OR REPLACE TABLE t1 AS SELECT * FROM t2;
CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1;
SET GLOBAL innodb_encryption_rotation_iops = 100;
SET GLOBAL innodb_encrypt_tables = OFF;
CREATE OR REPLACE TABLE t2 AS SELECT * FROM t1;
CREATE OR REPLACE TABLE t1 AS SELECT * FROM t2;
dec $i;
}

--enable_abort_on_error
--enable_warnings
--enable_query_log

drop table t1,t2;
SET GLOBAL innodb_encryption_threads = 0;

#
# MDEV-8173: InnoDB; Failing assertion: crypt_data->type == 1
#

SET GLOBAL innodb_encryption_threads = 4;

CREATE TABLE `table10_int_autoinc` (`col_int_key` int, pk int auto_increment, `col_int` int, key (`col_int_key` ),primary key (pk)) engine=innodb;
INSERT /*! IGNORE */ INTO table10_int_autoinc VALUES  (NULL, NULL, -474021888) ,  (1, NULL, NULL) ,  (1141047296, NULL, NULL) ,  (NULL, NULL, NULL) ,  (NULL, NULL, 1) ,  (NULL, NULL, 9) ,  (0, NULL, 1225785344) ,  (NULL, NULL, 1574174720) ,  (2, NULL, NULL) ,  (6, NULL, 3);

CREATE TABLE `table1_int_autoinc` (`col_int_key` int, pk int auto_increment, `col_int` int,key (`col_int_key` ), primary key (pk)) engine=innodb;

CREATE TABLE `table0_int_autoinc` (`col_int_key` int, pk int auto_increment, `col_int` int, key (`col_int_key` ),primary key (pk)) engine=innodb;

INSERT /*! IGNORE */ INTO table1_int_autoinc VALUES  (4, NULL, NULL);
INSERT IGNORE INTO `table0_int_autoinc` ( `col_int_key` ) VALUES ( 1 ), ( 3 ), ( 4 ), ( 1 );
INSERT IGNORE INTO `table1_int_autoinc` ( `col_int` ) VALUES ( 1 ), ( 0 ), ( 7 ), ( 9 );
INSERT IGNORE INTO `table10_int_autoinc` ( `col_int` ) VALUES ( 6 ), ( 2 ), ( 3 ), ( 6 );

--connect (con1,localhost,root,,test)
--connect (con2,localhost,root,,test)

--disable_abort_on_error
--disable_warnings
--disable_query_log

let $i = 500;
while ($i)
{
connection con1;
send SET GLOBAL innodb_encrypt_tables = ON;
connection default;
CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table1_int_autoinc`;
connection con2;
send CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table10_int_autoinc`;
connection default;
send CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table0_int_autoinc`;
connection con1;
--reap;
send SET GLOBAL innodb_encrypt_tables = OFF;
connection con2;
--reap;
connection default;
--reap;
send CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table1_int_autoinc`;
connection con2;
send CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table10_int_autoinc`;
connection con1;
--reap;
send SET GLOBAL innodb_encrypt_tables = ON;
connection default;
--reap;
send CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table1_int_autoinc`;
connection con2;
--reap;
CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table10_int_autoinc`;
CREATE OR REPLACE TABLE `create_or_replace_t` AS SELECT * FROM `table0_int_autoinc`;
connection con1;
--reap;
connection default;
--reap;
dec $i;
}

--enable_query_log
connection default;
drop table if exists create_or_replace_t, table1_int_autoinc, table0_int_autoinc, table10_int_autoinc;
--disconnect con1
--disconnect con2
--enable_abort_on_error
--enable_warnings

SET GLOBAL innodb_encrypt_tables = OFF;
SET GLOBAL innodb_encryption_threads = 4;

--echo # Wait max 10 min for key encryption threads to decrypt all spaces
let $cnt=600;
while ($cnt)
{
    let $success=`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0`;
    if ($success)
    {
        let $cnt=0;
    }
    if (!$success)
    {
        real_sleep 1;
        dec $cnt;
    }
}
if (!$success)
{
    SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION;
    SHOW STATUS LIKE 'innodb_encryption%';
    -- die Timeout waiting for encryption threads
}
--echo # Success!

SET GLOBAL innodb_encryption_threads = 0;
SET GLOBAL innodb_encrypt_tables = OFF;

# Make sure that all dirty pages are flushed

-- source include/restart_mysqld.inc