| 1 |
# This test does four operations, while changing the encryption type: |
| 2 |
# |
| 3 |
# - Moving table using file-per-table to another file-per-table. |
| 4 |
# - Moving table using file-per-table to general tablespace. |
| 5 |
# - Moving table using general tablespace to file-per-table. |
| 6 |
# - Moving table using general tablespace to another general tablespace. |
| 7 |
# |
| 8 |
# Error expected by corresponding ALTER TABLE: |
| 9 |
# $expected_error1 = ER_* |
| 10 |
# $expected_error2 = ER_* |
| 11 |
# $expected_error3 = ER_* |
| 12 |
# $expected_error4 = ER_* |
| 13 |
# |
| 14 |
# Parameter to set before including this file. |
| 15 |
# |
| 16 |
# $privilege_check = true/false - Setting for 'table_encryption_privilege_check' |
| 17 |
# $database_encryption = 'n' or 'y' - Default encryption type of database. |
| 18 |
# $table_encryption = 'n' or 'y' - Encryption type of Table used by source table. |
| 19 |
# $alter_tablespace_name = 'ts1' or predefined names. |
| 20 |
# $alter_encryption = 'n' or 'y' - Encryption type of Tablespace used in ALTER TABLE. |
| 21 |
# $has_grant = true/false - If User owns TABLE_ENCRYPTION_ADMIN |
| 22 |
# |
| 23 |
|
| 24 |
--let caseno=`SELECT $caseno+1` |
| 25 |
--echo # [ALTER TABLE] Case $caseno ) |
| 26 |
--echo ````````````````````````````````````````````````````````` |
| 27 |
|
| 28 |
eval CREATE DATABASE db1 DEFAULT ENCRYPTION=$database_encryption; |
| 29 |
eval CREATE TABLESPACE tsA ADD DATAFILE 'ts_a.ibd' ENCRYPTION=$table_encryption; |
| 30 |
if ($alter_tablespace_name == 'ts1') |
| 31 |
{ |
| 32 |
eval CREATE TABLESPACE $alter_tablespace_name ADD DATAFILE 'ts1.ibd' ENCRYPTION=$alter_encryption; |
| 33 |
} |
| 34 |
eval CREATE TABLE db1.t1 (f1 int) ENCRYPTION=$table_encryption; |
| 35 |
eval CREATE TABLE db1.t2 (f1 int) ENCRYPTION=$table_encryption; |
| 36 |
eval CREATE TABLE db1.t3 (f1 int) TABLESPACE=tsA ENCRYPTION=$table_encryption; |
| 37 |
eval CREATE TABLE db1.t4 (f1 int) TABLESPACE=tsA ENCRYPTION=$table_encryption; |
| 38 |
|
| 39 |
if ($has_grant == 'true') |
| 40 |
{ |
| 41 |
connection default; |
| 42 |
--echo # Grant TABLE_ENCRYPTION_ADMIN if requested. |
| 43 |
GRANT TABLE_ENCRYPTION_ADMIN ON *.* TO u1@localhost; |
| 44 |
connection con1; |
| 45 |
} |
| 46 |
|
| 47 |
eval SET GLOBAL table_encryption_privilege_check=$privilege_check; |
| 48 |
--echo # Run ALTER TABLE and check for errors/warnings |
| 49 |
--error $expected_error1 |
| 50 |
eval ALTER TABLE db1.t1 TABLESPACE=innodb_file_per_table ENCRYPTION=$alter_encryption; |
| 51 |
--error $expected_error2 |
| 52 |
eval ALTER TABLE db1.t2 TABLESPACE=$alter_tablespace_name ENCRYPTION=$alter_encryption; |
| 53 |
--error $expected_error3 |
| 54 |
eval ALTER TABLE db1.t3 TABLESPACE=innodb_file_per_table ENCRYPTION=$alter_encryption; |
| 55 |
--error $expected_error4 |
| 56 |
eval ALTER TABLE db1.t4 TABLESPACE=$alter_tablespace_name ENCRYPTION=$alter_encryption; |
| 57 |
eval SET GLOBAL table_encryption_privilege_check=false; |
| 58 |
|
| 59 |
--echo # Verify the ENCRYPTION clause value. |
| 60 |
SHOW CREATE TABLE db1.t1; |
| 61 |
SHOW CREATE TABLE db1.t2; |
| 62 |
SHOW CREATE TABLE db1.t3; |
| 63 |
SHOW CREATE TABLE db1.t4; |
| 64 |
--sorted_result |
| 65 |
SELECT TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES |
| 66 |
WHERE TABLE_SCHEMA='db1'; |
| 67 |
|
| 68 |
--echo # Cleanup |
| 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 tsA; |
| 78 |
if ($alter_tablespace_name == 'ts1') |
| 79 |
{ |
| 80 |
eval DROP TABLESPACE $alter_tablespace_name; |
| 81 |
} |
| 82 |
--let expected_error1=0 |
| 83 |
--let expected_error2=0 |
| 84 |
--let expected_error3=0 |
| 85 |
--let expected_error4=0 |