Debian Codegraph @

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

raw
1 # Parameter to set before including this file.
2
3 # $privilege_check = true/false
4 # $global_database_encryption_default = true/false
5 # $tablespace_encryption = 'n' or 'y'
6 # $tablespace_encryption_to = 'n' or 'y'
7 # $database_encryption = 'n' or 'y'
8 # $table_encryption_clause = 'n' or 'y'
9 # $alter_tablespace_error = ER_*
10
11 --let caseno=`SELECT $caseno+1`
12 --echo # [ALTER TABLESPACE] Case $caseno )
13 --echo `````````````````````````````````````````````````````````
14
15 if ($has_grant == 'true')
16 {
17 connection default;
18 --echo # Grant user with TABLE_ENCRYPTION_ADMIN
19 GRANT TABLE_ENCRYPTION_ADMIN ON *.* TO u1@localhost;
20 connection con1;
21 }
22
23 --echo # Create required schema to run ALTER TABLESPACE.
24 eval CREATE TABLESPACE ts1 ADD DATAFILE 'df_u.ibd' ENCRYPTION=$tablespace_encryption;
25 eval CREATE DATABASE db1 DEFAULT ENCRYPTION=$database_encryption;
26 if ($table1_encryption_clause == 'no')
27 {
28 eval CREATE TABLE db1.t1 (f1 int) TABLESPACE=ts1;
29 }
30 if ($table1_encryption_clause != 'no')
31 {
32 eval CREATE TABLE db1.t1 (f1 int) TABLESPACE=ts1 ENCRYPTION=$tablespace_encryption;
33 }
34 if ($table2_encryption_clause == 'no')
35 {
36 eval CREATE TABLE db1.t2 (f1 int) TABLESPACE=ts1;
37 }
38 if ($table2_encryption_clause != 'no')
39 {
40 eval CREATE TABLE db1.t2 (f1 int) TABLESPACE=ts1 ENCRYPTION=$tablespace_encryption;
41 }
42 SHOW CREATE TABLE db1.t1;
43 SHOW CREATE TABLE db1.t2;
44
45 # We assume default_table_encryption same desired tablespace encryption
46 # type, because our motive here is allow alter tablespace to succeed and
47 # observe what happens to ENCRYPTION clause of tables. The test
48 # encryption.tablespaces covers such test cases.
49 if ($tablespace_encryption_to == "'n'")
50 {
51 eval SET SESSION default_table_encryption=false;
52 }
53 if ($tablespace_encryption_to == "'y'")
54 {
55 eval SET SESSION default_table_encryption=true;
56 }
57
58 --echo # Run ALTER TABLESPACE
59 eval SET GLOBAL table_encryption_privilege_check=$privilege_check;
60 --error $alter_tablespace_error
61 eval ALTER TABLESPACE ts1 ENCRYPTION=$tablespace_encryption_to;
62 SHOW WARNINGS;
63 SHOW CREATE TABLE db1.t1;
64 SHOW CREATE TABLE db1.t2;
65 SET GLOBAL table_encryption_privilege_check=false;
66 SET SESSION default_table_encryption=false;
67
68 --echo # clean up
69 if ($has_grant == 'true')
70 {
71 connection default;
72 --echo # Revoke TABLE_ENCRYPTION_ADMIN from user
73 REVOKE TABLE_ENCRYPTION_ADMIN ON *.* FROM u1@localhost;
74 connection con1;
75 }
76 DROP DATABASE db1;
77 DROP TABLESPACE ts1;
78 --echo #