diff --git a/mysql-test/suite/innodb/r/temp_table_encrypt.result b/mysql-test/suite/innodb/r/temp_table_encrypt.result index 851099a697eb..ad86cc72a749 100644 --- a/mysql-test/suite/innodb/r/temp_table_encrypt.result +++ b/mysql-test/suite/innodb/r/temp_table_encrypt.result @@ -1,5 +1,16 @@ call mtr.add_suppression("\\[Error\\] InnoDB: keyring error: please check that a keyring plugin is loaded"); call mtr.add_suppression("\\[Error\\] InnoDB: Can't set temporary tablespace to be encrypted because keyring plugin is not available"); +# +# PS-4727: instrinsic temp table behaviour shouldn't depend on innodb_encrypt_tables +# +CREATE TABLE t1 (a INT, b BLOB); +INSERT INTO t1 VALUES (1, 'hello'), (2, 'hi'), (3, 'satya'); +SET GLOBAL innodb_encrypt_tables=ON; +SET big_tables=ON; +INSERT INTO t1 SELECT * FROM t1; +DROP TABLE t1; +SET big_tables=default; +SET GLOBAL innodb_encrypt_tables=default; # without keyring plugin, try to enable encryption of temporary # tablespace SELECT @@innodb_temp_tablespace_encrypt; diff --git a/mysql-test/suite/innodb/t/temp_table_encrypt.test b/mysql-test/suite/innodb/t/temp_table_encrypt.test index b19d3d2c4d87..d0dae665f9bc 100644 --- a/mysql-test/suite/innodb/t/temp_table_encrypt.test +++ b/mysql-test/suite/innodb/t/temp_table_encrypt.test @@ -4,6 +4,18 @@ call mtr.add_suppression("\\[Error\\] InnoDB: keyring error: please check that a keyring plugin is loaded"); call mtr.add_suppression("\\[Error\\] InnoDB: Can't set temporary tablespace to be encrypted because keyring plugin is not available"); +--echo # +--echo # PS-4727: instrinsic temp table behaviour shouldn't depend on innodb_encrypt_tables +--echo # +CREATE TABLE t1 (a INT, b BLOB); +INSERT INTO t1 VALUES (1, 'hello'), (2, 'hi'), (3, 'satya'); +SET GLOBAL innodb_encrypt_tables=ON; +SET big_tables=ON; +INSERT INTO t1 SELECT * FROM t1; +DROP TABLE t1; +SET big_tables=default; +SET GLOBAL innodb_encrypt_tables=default; + --echo # without keyring plugin, try to enable encryption of temporary --echo # tablespace SELECT @@innodb_temp_tablespace_encrypt; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b0d5c7b0139b..784b80392c07 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12045,10 +12045,15 @@ ha_innobase::adjust_create_info_for_frm( bool is_intrinsic = (create_info->options & HA_LEX_CREATE_INTERNAL_TMP_TABLE) != 0; + /* If table is intrinsic, it will use encryption for table based on + temporary tablespace encryption property. For non-intrinsic tables + without explicit encryption attribute, table will be forced to be + encrypted if innodb_encrypt_tables=ON/FORCE */ if (create_info->encrypt_type.length == 0 && create_info->encrypt_type.str == NULL - && (srv_encrypt_tables != SRV_ENCRYPT_TABLES_OFF - || (srv_tmp_space.is_encrypted() && is_intrinsic))) { + && ((is_intrinsic && srv_tmp_space.is_encrypted()) + || (!is_intrinsic + && srv_encrypt_tables != SRV_ENCRYPT_TABLES_OFF))) { create_info->encrypt_type = yes_string; } }