| 1 |
# Parameter to set before including this file. |
| 2 |
|
| 3 |
# $privilege_check = true/false |
| 4 |
# $database_encryption = 'n' or 'y' |
| 5 |
# $table_encryption = 'n' or 'y' |
| 6 |
# $alter_tablespace_name = 'ts1' or predefined names. |
| 7 |
# $alter_encryption = 'n' or 'y' |
| 8 |
# |
| 9 |
# $expected_error1 = ER_* |
| 10 |
# $expected_error2 = ER_* |
| 11 |
# $expected_error3 = ER_* |
| 12 |
# $expected_error4 = ER_* |
| 13 |
|
| 14 |
--let caseno=`SELECT $caseno+1` |
| 15 |
--echo # [ALTER TABLE ... RENAME ...] Case $caseno ) |
| 16 |
--echo ````````````````````````````````````````````````````````` |
| 17 |
|
| 18 |
eval CREATE DATABASE db1 DEFAULT ENCRYPTION='y'; |
| 19 |
eval CREATE DATABASE db2 DEFAULT ENCRYPTION='n'; |
| 20 |
|
| 21 |
eval CREATE DATABASE sch1 DEFAULT ENCRYPTION='y'; |
| 22 |
eval CREATE DATABASE sch2 DEFAULT ENCRYPTION='n'; |
| 23 |
|
| 24 |
if ($alter_tablespace_name == 'ts1') |
| 25 |
{ |
| 26 |
eval CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENCRYPTION=$table_encryption; |
| 27 |
} |
| 28 |
|
| 29 |
eval CREATE TABLE db1.fpt1 (f1 int) ENCRYPTION=$table_encryption; |
| 30 |
eval CREATE TABLE db1.fpt2 (f1 int) ENCRYPTION=$table_encryption; |
| 31 |
eval CREATE TABLE db1.ts1 (f1 int) TABLESPACE=$alter_tablespace_name ENCRYPTION=$table_encryption; |
| 32 |
eval CREATE TABLE db1.ts2 (f1 int) TABLESPACE=$alter_tablespace_name ENCRYPTION=$table_encryption; |
| 33 |
eval CREATE TABLE db2.fpt1 (f1 int) ENCRYPTION=$table_encryption; |
| 34 |
eval CREATE TABLE db2.fpt2 (f1 int) ENCRYPTION=$table_encryption; |
| 35 |
eval CREATE TABLE db2.ts1 (f1 int) TABLESPACE=$alter_tablespace_name ENCRYPTION=$table_encryption; |
| 36 |
eval CREATE TABLE db2.ts2 (f1 int) TABLESPACE=$alter_tablespace_name ENCRYPTION=$table_encryption; |
| 37 |
|
| 38 |
eval CREATE TABLE sch1.fpt (f1 int) ENCRYPTION=$table_encryption; |
| 39 |
eval CREATE TABLE sch1.ts (f1 int) TABLESPACE=$alter_tablespace_name ENCRYPTION=$table_encryption; |
| 40 |
eval CREATE TABLE sch2.fpt (f1 int) ENCRYPTION=$table_encryption; |
| 41 |
eval CREATE TABLE sch2.ts (f1 int) TABLESPACE=$alter_tablespace_name ENCRYPTION=$table_encryption; |
| 42 |
|
| 43 |
eval SET GLOBAL table_encryption_privilege_check=$privilege_check; |
| 44 |
|
| 45 |
if ($has_grant == 'true') |
| 46 |
{ |
| 47 |
connection default; |
| 48 |
--echo # Grant user with TABLE_ENCRYPTION_ADMIN |
| 49 |
GRANT TABLE_ENCRYPTION_ADMIN ON *.* TO u1@localhost; |
| 50 |
connection con1; |
| 51 |
} |
| 52 |
|
| 53 |
--echo # $caseno.1. |
| 54 |
--echo # Rename table using file-per-table tablespace from db encryption='y' |
| 55 |
--echo # to db with encryption='n' and viceversa |
| 56 |
--error $expected_error1 |
| 57 |
eval RENAME TABLE db1.fpt1 TO db2.fpt1_renamed; |
| 58 |
--error $expected_error2 |
| 59 |
eval RENAME TABLE db2.fpt1 TO db1.fpt1_renamed; |
| 60 |
|
| 61 |
--echo # $caseno.2. |
| 62 |
--echo # Rename table using general tablespace from db encryption='y' |
| 63 |
--echo # to db with encryption='n' and viceversa |
| 64 |
--error $expected_error3 |
| 65 |
eval RENAME TABLE db1.ts1 TO db2.ts1_rename; |
| 66 |
--error $expected_error4 |
| 67 |
eval RENAME TABLE db2.ts1 TO db1.ts1_rename; |
| 68 |
|
| 69 |
--echo # $caseno.3. |
| 70 |
--echo # Rename table (using file-per-table/general tablespace) |
| 71 |
--echo # within the database never fails. |
| 72 |
eval RENAME TABLE sch1.fpt TO sch1.fpt_renamed; |
| 73 |
eval RENAME TABLE sch1.ts TO sch1.ts_renamed; |
| 74 |
eval RENAME TABLE sch2.fpt TO sch2.fpt_renamed; |
| 75 |
eval RENAME TABLE sch2.ts TO sch2.ts_renamed; |
| 76 |
|
| 77 |
eval SET GLOBAL table_encryption_privilege_check=false; |
| 78 |
SHOW TABLES IN db1; |
| 79 |
SHOW TABLES IN db2; |
| 80 |
SHOW TABLES IN sch1; |
| 81 |
SHOW TABLES IN sch2; |
| 82 |
|
| 83 |
if ($has_grant == 'true') |
| 84 |
{ |
| 85 |
connection default; |
| 86 |
--echo # Revoke TABLE_ENCRYPTION_ADMIN from user. |
| 87 |
REVOKE TABLE_ENCRYPTION_ADMIN ON *.* FROM u1@localhost; |
| 88 |
connection con1; |
| 89 |
} |
| 90 |
|
| 91 |
# clean up |
| 92 |
DROP DATABASE db1; |
| 93 |
DROP DATABASE db2; |
| 94 |
DROP DATABASE sch1; |
| 95 |
DROP DATABASE sch2; |
| 96 |
|
| 97 |
if ($alter_tablespace_name == 'ts1') |
| 98 |
{ |
| 99 |
eval DROP TABLESPACE $alter_tablespace_name; |
| 100 |
} |
| 101 |
|
| 102 |
--let expected_error1=0 |
| 103 |
--let expected_error2=0 |
| 104 |
--let expected_error3=0 |
| 105 |
--let expected_error4=0 |