Skip to content

Commit

Permalink
Merge pull request #2481 from satya-bodapati/PS-5.7-4727
Browse files Browse the repository at this point in the history
PS-4727 - intrinsic temp table behaviour shouldn't depend on innodb_e…
  • Loading branch information
satya-bodapati authored Aug 13, 2018
2 parents 8dc1f3d + df3b5ca commit e0dd2f8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
11 changes: 11 additions & 0 deletions mysql-test/suite/innodb/r/temp_table_encrypt.result
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 12 additions & 0 deletions mysql-test/suite/innodb/t/temp_table_encrypt.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit e0dd2f8

Please sign in to comment.