Debian Codegraph @

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

raw
1 --echo #
2 --echo # WL#12261 Control (enforce and disable) table encryption
3 --echo #
4 --source include/have_debug.inc
5
6 --echo # Pre-define user u1, which is used in different tests below.
7 CREATE USER u1@localhost;
8 GRANT ALL ON db1.* TO u1@localhost;
9 GRANT ALL ON db2.* TO u1@localhost;
10 GRANT ALL ON sch1.* TO u1@localhost;
11 GRANT ALL ON sch2.* TO u1@localhost;
12 GRANT CREATE TABLESPACE, PROCESS, SYSTEM_VARIABLES_ADMIN ON *.* TO u1@localhost;
13 SET GLOBAL debug= '+d,skip_table_encryption_admin_check_for_set';
14 connect (con1, localhost, u1);
15
16 --echo # The test cases run ALTER TABLE RENAME to move tables from one database
17 --echo # to another, with tables using file-per-table or general
18 --echo # tablespace. And these operations are run in below configuration,
19 --echo #
20 --echo # - Setting table_encryption_privilege_check to true/false.
21 --echo # - Setting per database default encryption to 'y' and 'n'
22 --echo # - Setting table's encryption mode to 'y' and 'n'.
23 --echo # - With and without user holding TABLE_ENCRYPTION_ADMIN privilege.
24 --echo # -
25 --echo # - Check for warnings generated.
26 --echo #
27
28
29 --echo `````````````````````````````````````````````````````````
30 --echo # Test using innodb_file_per_table tablespace.
31 --let alter_tablespace_name=innodb_file_per_table
32 --let expected_error1=0
33 --let expected_error2=0
34 --let expected_error3=0
35 --let expected_error4=0
36 --let caseno=0
37
38 --echo `````````````````````````````````````````````````````````
39 --echo # table_encryption_privilege_check=false
40 --let privilege_check=false
41
42 --let table_encryption='n'
43 --source ./alter_rename_table.inc
44 --let table_encryption='y'
45 --source ./alter_rename_table.inc
46
47 --echo `````````````````````````````````````````````````````````
48 --echo # table_encryption_privilege_check=true
49 --let privilege_check=true
50
51 --echo `````````````````````````````````````````````````````````
52 --echo # We expect failure when the table encryption does not match
53 --echo # with default database encryption.
54 --let table_encryption='n'
55 --let expected_error2=ER_CANNOT_SET_TABLE_ENCRYPTION
56 --let expected_error4=ER_CANNOT_SET_TABLE_ENCRYPTION
57 --source ./alter_rename_table.inc
58
59 --let has_grant=true
60 --let table_encryption='n'
61 --source ./alter_rename_table.inc
62 --let has_grant=false
63
64 --echo `````````````````````````````````````````````````````````
65 --echo # We expect failure when the table encryption does not match
66 --echo # with default database encryption.
67 --let table_encryption='y'
68 --let expected_error1=ER_CANNOT_SET_TABLE_ENCRYPTION
69 --let expected_error3=ER_CANNOT_SET_TABLE_ENCRYPTION
70 --source ./alter_rename_table.inc
71
72 --let has_grant=true
73 --let table_encryption='y'
74 --source ./alter_rename_table.inc
75 --let has_grant=false
76
77 --echo `````````````````````````````````````````````````````````
78 --echo # Test using general tablespace.
79 --let alter_tablespace_name=ts1
80 --let expected_error1=0
81 --let expected_error2=0
82 --let expected_error3=0
83 --let expected_error4=0
84
85 --echo `````````````````````````````````````````````````````````
86 --echo # table_encryption_privilege_check=false
87 --let privilege_check=false
88
89 --let table_encryption='n'
90 --source ./alter_rename_table.inc
91 --let table_encryption='y'
92 --source ./alter_rename_table.inc
93
94 --echo `````````````````````````````````````````````````````````
95 --echo # table_encryption_privilege_check=true
96 --let privilege_check=true
97
98 --echo `````````````````````````````````````````````````````````
99 --echo # We expect failure when the table encryption does not match
100 --echo # with default database encryption.
101 --let table_encryption='n'
102 --let expected_error2=ER_CANNOT_SET_TABLE_ENCRYPTION
103 --let expected_error4=ER_CANNOT_SET_TABLE_ENCRYPTION
104 --source ./alter_rename_table.inc
105
106 --let has_grant=true
107 --let table_encryption='n'
108 --source ./alter_rename_table.inc
109 --let has_grant=false
110
111 --echo `````````````````````````````````````````````````````````
112 --echo # We expect failure when the table encryption does not match
113 --echo # with default database encryption.
114 --let table_encryption='y'
115 --let expected_error1=ER_CANNOT_SET_TABLE_ENCRYPTION
116 --let expected_error3=ER_CANNOT_SET_TABLE_ENCRYPTION
117 --source ./alter_rename_table.inc
118
119 --let has_grant=true
120 --let table_encryption='y'
121 --source ./alter_rename_table.inc
122 --let has_grant=false
123
124 --let algo=copy
125
126 --echo `````````````````````````````````````````````````````````
127 --echo # table_encryption_privilege_check=false
128 --let privilege_check=false
129
130 --let table_encryption='n'
131 --source ./alter_rename_table.inc
132 --let table_encryption='y'
133 --source ./alter_rename_table.inc
134
135 --echo `````````````````````````````````````````````````````````
136 --echo # table_encryption_privilege_check=true
137 --let privilege_check=true
138
139 --echo `````````````````````````````````````````````````````````
140 --echo # We expect failure when the table encryption does not match
141 --echo # with default database encryption.
142 --let table_encryption='n'
143 --let expected_error2=ER_CANNOT_SET_TABLE_ENCRYPTION
144 --let expected_error4=ER_CANNOT_SET_TABLE_ENCRYPTION
145 --source ./alter_rename_table.inc
146
147 --let has_grant=true
148 --let table_encryption='n'
149 --source ./alter_rename_table.inc
150 --let has_grant=false
151
152 --echo `````````````````````````````````````````````````````````
153 --echo # We expect failure when the table encryption does not match
154 --echo # with default database encryption.
155 --let table_encryption='y'
156 --let expected_error1=ER_CANNOT_SET_TABLE_ENCRYPTION
157 --let expected_error3=ER_CANNOT_SET_TABLE_ENCRYPTION
158 --source ./alter_rename_table.inc
159
160 --let has_grant=true
161 --let table_encryption='y'
162 --source ./alter_rename_table.inc
163 --let has_grant=false
164
165 --let algo=inplace
166
167 --echo `````````````````````````````````````````````````````````
168 --echo # table_encryption_privilege_check=false
169 --let privilege_check=false
170
171 --let table_encryption='n'
172 --source ./alter_rename_table.inc
173 --let table_encryption='y'
174 --source ./alter_rename_table.inc
175
176 --echo `````````````````````````````````````````````````````````
177 --echo # table_encryption_privilege_check=true
178 --let privilege_check=true
179
180 --echo `````````````````````````````````````````````````````````
181 --echo # We expect failure when the table encryption does not match
182 --echo # with default database encryption.
183 --let table_encryption='n'
184 --let expected_error2=ER_CANNOT_SET_TABLE_ENCRYPTION
185 --let expected_error4=ER_CANNOT_SET_TABLE_ENCRYPTION
186 --source ./alter_rename_table.inc
187
188 --let has_grant=true
189 --let table_encryption='y'
190 --source ./alter_rename_table.inc
191 --let has_grant=false
192
193 --echo `````````````````````````````````````````````````````````
194 --echo # We expect failure when the table encryption does not match
195 --echo # with default database encryption.
196 --let table_encryption='y'
197 --let expected_error1=ER_CANNOT_SET_TABLE_ENCRYPTION
198 --let expected_error3=ER_CANNOT_SET_TABLE_ENCRYPTION
199 --source ./alter_rename_table.inc
200
201 --let has_grant=true
202 --let table_encryption='y'
203 --source ./alter_rename_table.inc
204 --let has_grant=false
205
206
207 --echo # Cleanup
208 disconnect con1;
209 connection default;
210 DROP USER u1@localhost;
211 SET GLOBAL debug= '-d,skip_table_encryption_admin_check_for_set';