Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS-4727 - intrinsic temp table behaviour shouldn't depend on innodb_e… #2481

Merged
merged 1 commit into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of manipulating big_tables, a shorter version would be SELECT SQL_BIG_RESULT ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From documentation, "SQL_BIG_RESULT or SQL_SMALL_RESULT can be used with GROUP BY or DISTINCT to tell the optimizer that the result set has many rows or is small, respectively.'
Since I am using INSERT SELECT (although it may work), I would prefer SET big_tables here.

BTW, this is added as safety measure. With BLOBs, innodb storage engine is used in 5.7. In future (with temptable engine in 8.0 etc), this may not be true. So I added this protection

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