Debian Codegraph @

mysql-test/suite/encryption/t/tablespace_with_tables.test

raw
1 --echo #
2 --echo # WL#12261 Control (enforce and disable) table encryption
3 --echo #
4
5 --source include/have_debug.inc
6
7 --echo # Pre-define user u1, which is used in different tests below.
8 CREATE USER u1@localhost;
9 GRANT ALL ON db1.* TO u1@localhost;
10 GRANT CREATE TABLESPACE, PROCESS, SYSTEM_VARIABLES_ADMIN ON *.* TO u1@localhost;
11 SET GLOBAL debug= '+d,skip_table_encryption_admin_check_for_set';
12
13 connect (con1, localhost, u1);
14
15 --echo # The test cases run ALTER TABLESPACE to check its encryption mode.
16 --echo # The importance of this test is to check the way ALTER TABLESPACE
17 --echo # updates the ENCRYPTION clause of tables in it.
18 --echo # We run this command in various configuration as,
19 --echo #
20 --echo # - Setting table_encryption_privilege_check to true/false.
21 --echo # - Setting per database default encryption to true/false.
22 --echo # - With and without user holding TABLE_ENCRYPTION_ADMIN privilege.
23 --echo # - Check for warnings generated.
24 --echo #
25
26 --let table1_encryption_clause=yes
27 --let table2_encryption_clause=yes
28 --let caseno=0
29
30 --echo `````````````````````````````````````````````````````````
31 --echo # Unencrypted TABLESPACE to Unencrypted TABLESPACE (Nop)
32 --let database_encryption='n'
33 --let tablespace_encryption='n'
34 --let tablespace_encryption_to='n'
35
36 --let privilege_check=false
37 --let alter_tablespace_error=0
38 --source ./tablespace_with_tables.inc
39
40 --let privilege_check=true
41 --let alter_tablespace_error=0
42 --source ./tablespace_with_tables.inc
43
44
45 --echo `````````````````````````````````````````````````````````
46 --echo # Encrypted TABLESPACE to Encrypted TABLESPACE (Nop)
47 --let database_encryption='y'
48 --let tablespace_encryption='y'
49 --let tablespace_encryption_to='y'
50
51 --let privilege_check=false
52 --let alter_tablespace_error=0
53 --source ./tablespace_with_tables.inc
54
55 --let privilege_check=true
56 --let alter_tablespace_error=0
57 --source ./tablespace_with_tables.inc
58 --let has_grant=true
59 --let alter_tablespace_error=0
60 --source ./tablespace_with_tables.inc
61 --let has_grant=false
62
63
64 --echo `````````````````````````````````````````````````````````
65 --echo # Unencrypted TABLESPACE to encrypted TABLESPACE
66 --echo # with database encryption default 'n'
67 --let database_encryption='n'
68 --let tablespace_encryption='n'
69 --let tablespace_encryption_to='y'
70
71 --let privilege_check=false
72 --let alter_tablespace_error=0
73 --source ./tablespace_with_tables.inc
74
75 --echo `````````````````````````````````````````````````````````
76 --echo # Reject creating encrypted table in database with default encryption='n'
77 --let privilege_check=true
78 --let alter_tablespace_error=ER_TABLESPACE_CANNOT_BE_ENCRYPTED
79 --source ./tablespace_with_tables.inc
80
81 --let has_grant=true
82 --let alter_tablespace_error=0
83 --source ./tablespace_with_tables.inc
84 --let has_grant=false
85
86 --echo # With some tables without ENCRYPTION clause;
87 --let table2_encryption_clause=no
88
89 --let privilege_check=false
90 --let alter_tablespace_error=0
91 --source ./tablespace_with_tables.inc
92
93 --echo `````````````````````````````````````````````````````````
94 --echo # Reject creating encrypted table in database with default encryption='n'
95 --let privilege_check=true
96 --let alter_tablespace_error=ER_TABLESPACE_CANNOT_BE_ENCRYPTED
97 --source ./tablespace_with_tables.inc
98 --let has_grant=true
99 --let alter_tablespace_error=0
100 --source ./tablespace_with_tables.inc
101 --let has_grant=false
102
103 --let table2_encryption_clause=yes
104
105 --echo # With all tables without ENCRYPTION clause;
106 --let table1_encryption_clause=no
107 --let table2_encryption_clause=no
108
109 --let privilege_check=false
110 --let alter_tablespace_error=0
111 --source ./tablespace_with_tables.inc
112
113 --echo `````````````````````````````````````````````````````````
114 --echo # Request to create encrypted tablespace with default_table_encryption='n'
115 --let privilege_check=true
116 --let alter_tablespace_error=ER_TABLESPACE_CANNOT_BE_ENCRYPTED
117 --source ./tablespace_with_tables.inc
118 --let has_grant=true
119 --let alter_tablespace_error=0
120 --source ./tablespace_with_tables.inc
121 --let has_grant=false
122
123 --let table1_encryption_clause=yes
124 --let table2_encryption_clause=yes
125
126
127 --echo `````````````````````````````````````````````````````````
128 --echo # Unencrypted TABLESPACE to encrypted TABLESPACE
129 --echo # with database encryption 'y'
130 --let database_encryption='y'
131 --let tablespace_encryption='n'
132 --let tablespace_encryption_to='y'
133
134 --let privilege_check=false
135 --let alter_tablespace_error=0
136 --source ./tablespace_with_tables.inc
137
138 --let privilege_check=true
139 --let alter_tablespace_error=0
140 --source ./tablespace_with_tables.inc
141 --let has_grant=true
142 --let alter_tablespace_error=0
143 --source ./tablespace_with_tables.inc
144 --let has_grant=false
145
146 --echo # Case $caseno.1 With some tables without ENCRYPTION clause;
147 --echo # CREATE table using unencrypted tablespace without
148 --echo # ENCRYPTION clause would inherit ENCRYPTION from database.
149 --echo # This makes CREATE TABLE fail because the ENCRYPTION clause
150 --echo # and the tablespace encryption type mismatches. The test
151 --echo # encryption.create_table does test this.
152
153 --echo # Case $caseno.2 With all tables without ENCRYPTION clause;
154 --echo # Behavior would be same as described in Case $caseno.1
155
156 --echo `````````````````````````````````````````````````````````
157 --echo # Encrypted TABLESPACE to unencrypted TABLESPACE
158 --echo # with database encryption 'n'
159 --let database_encryption='n'
160 --let tablespace_encryption='y'
161 --let tablespace_encryption_to='n'
162
163 --let privilege_check=false
164 --let alter_tablespace_error=0
165 --source ./tablespace_with_tables.inc
166
167 --let privilege_check=true
168 --let alter_tablespace_error=0
169 --source ./tablespace_with_tables.inc
170 --let has_grant=true
171 --let alter_tablespace_error=0
172 --source ./tablespace_with_tables.inc
173 --let has_grant=false
174
175
176 --echo `````````````````````````````````````````````````````````
177 --echo # Encrypted TABLESPACE to unencrypted TABLESPACE
178 --echo # with database encryption 'y'
179 --let database_encryption='y'
180 --let tablespace_encryption='y'
181 --let tablespace_encryption_to='n'
182
183 --let privilege_check=false
184 --let alter_tablespace_error=0
185 --source ./tablespace_with_tables.inc
186
187 --let privilege_check=true
188 --echo `````````````````````````````````````````````````````````
189 --echo # Request to create unencrypted tablespace with default_table_encryption='y'
190 --let alter_tablespace_error=ER_TABLESPACE_CANNOT_BE_DECRYPTED
191 --source ./tablespace_with_tables.inc
192 --let has_grant=true
193 --let alter_tablespace_error=0
194 --source ./tablespace_with_tables.inc
195 --let has_grant=false
196
197 --echo # Clean up.
198 connection default;
199 DROP USER u1@localhost;
200 SET GLOBAL debug= '-d,skip_table_encryption_admin_check_for_set';