1--echo #
2--echo # Bug#30787535 : FULLTEXT INDEX TABLES CREATED IN ENCRYPTED SCHEMA ARE NOT ENCRYPTED
3--echo #
4
5################################################################################
6# For an encrypted table, this test case checks physical ibd file for :
7#	- table
8#	- fts table created for an FTS index on table
9#	- Other aux tables created for FTS index
10#  to see if they are encrypted.
11################################################################################
12--source include/have_debug.inc
13# Disable in valgrind because of timeout, cf. Bug#22760145
14--source include/not_valgrind.inc
15# Waiting time when (re)starting the server
16--let $explicit_default_counter=10000
17
18--echo #########
19--echo # SETUP #
20--echo #########
21--echo
22let datadir=`SELECT @@datadir`;
23let search_pattern=supremum;
24
25--echo #########################################################################
26--echo # RESTART 1 : WITH KEYRING PLUGIN
27--echo #########################################################################
28let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT;
29--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $KEYRING_PLUGIN keyring_file.so
30--replace_regex /\.dll/.so/
31--source include/restart_mysqld.inc
32
33--echo # Create a new 'unencrypted' table
34CREATE TABLE t1 (id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
35                 C1 TEXT(500),
36                 C2 VARCHAR(200),
37                 C3 VARCHAR(200)) ENCRYPTION='N' ENGINE=InnoDB;
38
39# Make sure all pages are flushed
40set global innodb_buf_flush_list_now = 1;
41
42--echo # ---------------------------------------------------------------
43--echo # Test 1 : t1 un-encrypted, FTS tables should also be unencrypted
44--echo # ---------------------------------------------------------------
45--echo # Check that tablespace file is not encrypted
46--let ts_name=test/t1.ibd
47--source include/if_encrypted.inc
48
49CREATE FULLTEXT INDEX idx ON t1(C1);
50
51# Make sure all pages are flushed
52set global innodb_buf_flush_list_now = 1;
53
54--let ts_name = `select NAME from information_schema.innodb_sys_tables where name like "%INDEX_1%";`
55--let ts_name = $ts_name.ibd
56--echo # Check that FTS tablespaces file is not encrypted
57--source include/if_encrypted.inc
58
59--echo # ---------------------------------------------------------------
60--echo # Test 1 : t1 encrypted, FTS tables should also be unencrypted
61--echo # ---------------------------------------------------------------
62# Now, change the encryption property of table
63ALTER TABLE t1 ENCRYPTION='Y';
64
65--echo # Check that tablespace file is encrypted now
66--let ts_name=test/t1.ibd
67--source include/if_encrypted.inc
68
69--let ts_name = `select NAME from information_schema.innodb_sys_tables where name like "%INDEX_1%";`
70--let ts_name = $ts_name.ibd
71--echo # Check that FTS tablespace file is encrypted now
72--source include/if_encrypted.inc
73
74--echo ###########
75--echo # CLEANUP #
76--echo ###########
77DROP TABLE test.t1;
78remove_file $MYSQLTEST_VARDIR/tmpfile.txt;
79remove_file $MYSQL_TMP_DIR/mysecret_keyring;
80
81--echo # Restarting server without keyring to restore server state
82let $restart_parameters = restart: ;
83--source include/restart_mysqld.inc
84