| 1 |
# Parameters to set before including this file. |
| 2 |
|
| 3 |
# $privilege_check = true/false |
| 4 |
# |
| 5 |
# $database_encryption = 'n' or 'y' |
| 6 |
# |
| 7 |
# $explicit_encryption_clause = true/false |
| 8 |
# $table_encryption = 'n' or 'y' |
| 9 |
# |
| 10 |
# $use_tablespace = true/false |
| 11 |
# $tablespace_name = 'ts1' or predefined names. |
| 12 |
# |
| 13 |
# $expected_error = ER_* |
| 14 |
# $expected_error2 = ER_* |
| 15 |
|
| 16 |
--let caseno=`SELECT $caseno+1` |
| 17 |
--echo # [CREATE TABLE] Case $caseno ) |
| 18 |
--echo ````````````````````````````````````````````````````````` |
| 19 |
|
| 20 |
if ($use_tablespace == 'true') |
| 21 |
{ |
| 22 |
if ($tablespace_name == 'ts1') |
| 23 |
{ |
| 24 |
eval CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENCRYPTION=$table_encryption; |
| 25 |
} |
| 26 |
} |
| 27 |
eval CREATE DATABASE db1 DEFAULT ENCRYPTION=$database_encryption; |
| 28 |
|
| 29 |
eval SET GLOBAL table_encryption_privilege_check=$privilege_check; |
| 30 |
if ($use_tablespace == 'true') |
| 31 |
{ |
| 32 |
if ($explicit_encryption_clause != 'true') |
| 33 |
{ |
| 34 |
--let create_ddl=CREATE TABLE db1.t1 (f1 int) TABLESPACE=$tablespace_name |
| 35 |
} |
| 36 |
if ($explicit_encryption_clause == 'true') |
| 37 |
{ |
| 38 |
--let create_ddl=CREATE TABLE db1.t1 (f1 int) TABLESPACE=$tablespace_name ENCRYPTION=$table_encryption |
| 39 |
} |
| 40 |
} |
| 41 |
if ($use_tablespace != 'true') |
| 42 |
{ |
| 43 |
if ($explicit_encryption_clause != 'true') |
| 44 |
{ |
| 45 |
--let create_ddl=CREATE TABLE db1.t1 (f1 int) |
| 46 |
} |
| 47 |
if ($explicit_encryption_clause == 'true') |
| 48 |
{ |
| 49 |
--let create_ddl=CREATE TABLE db1.t1 (f1 int) ENCRYPTION=$table_encryption |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
--error $expected_error |
| 54 |
eval $create_ddl; |
| 55 |
|
| 56 |
if ($expected_error == '0') |
| 57 |
{ |
| 58 |
SHOW CREATE TABLE db1.t1; |
| 59 |
SELECT TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES |
| 60 |
WHERE TABLE_NAME='t1'; |
| 61 |
DROP TABLE db1.t1; |
| 62 |
} |
| 63 |
|
| 64 |
if ($privilege_check == 'true') |
| 65 |
{ |
| 66 |
if ($expected_error == 'ER_CANNOT_SET_TABLE_ENCRYPTION') |
| 67 |
{ |
| 68 |
connection default; |
| 69 |
--echo # GRANT user the TABLE_ENCRYPTION_ADMIN |
| 70 |
GRANT TABLE_ENCRYPTION_ADMIN ON *.* TO u1@localhost; |
| 71 |
connection con1; |
| 72 |
|
| 73 |
# The create table would still fail if the encryption clause does not |
| 74 |
# match the tablespace encryption type. |
| 75 |
--error $expected_error2 |
| 76 |
eval $create_ddl; |
| 77 |
|
| 78 |
if ($expected_error == '0') |
| 79 |
{ |
| 80 |
SHOW CREATE TABLE db1.t1; |
| 81 |
SELECT TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES |
| 82 |
WHERE TABLE_NAME='t1'; |
| 83 |
DROP TABLE db1.t1; |
| 84 |
} |
| 85 |
|
| 86 |
connection default; |
| 87 |
--echo # REVOKE TABLE_ENCRYPTION_ADMIN from user. |
| 88 |
REVOKE TABLE_ENCRYPTION_ADMIN ON *.* FROM u1@localhost; |
| 89 |
connection con1; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
# Clean up |
| 94 |
DROP DATABASE db1; |
| 95 |
if ($use_tablespace == 'true') |
| 96 |
{ |
| 97 |
if ($tablespace_name == 'ts1') |
| 98 |
{ |
| 99 |
DROP TABLESPACE ts1; |
| 100 |
} |
| 101 |
} |
| 102 |
SET GLOBAL table_encryption_privilege_check=false; |