[Commits] c1bc173b6fa: After review fixes.
revision-id: c1bc173b6fa0e50134f52b84fa184e00b65fc748 (mariadb-10.1.37-8-gc1bc173b6fa) parent(s): 9c46adbb7e093029c56dddd5dbbef407db4e8160 author: Jan Lindström committer: Jan Lindström timestamp: 2018-11-14 10:12:24 +0200 message: After review fixes. --- .../encryption/r/innodb-checksum-algorithm.result | 2 +- .../encryption/r/innodb-compressed-blob.result | 2 -- .../encryption/r/innodb-encryption-alter.result | 4 +-- .../r/innodb_encryption_default_key.result | 19 ++++++++++++-- .../encryption/t/innodb-checksum-algorithm.test | 6 +---- .../encryption/t/innodb-encryption-alter.test | 3 +-- .../t/innodb_encryption_default_key.test | 15 ++++++++++- storage/innobase/fil/fil0crypt.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 29 +++++++++++----------- storage/innobase/include/ha_prototypes.h | 6 ++--- storage/xtradb/fil/fil0crypt.cc | 2 +- storage/xtradb/handler/ha_innodb.cc | 29 +++++++++++----------- storage/xtradb/include/ha_prototypes.h | 6 ++--- 13 files changed, 72 insertions(+), 53 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result index b3deac98e3c..a853f3869a9 100644 --- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result +++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result @@ -10,7 +10,7 @@ SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encryption_threads = 4; call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to \"strict_(crc32|none|innodb)\" but the page \\[page id: space=[0-9]+, page number=[0-9]+\\] contains a valid checksum \"(innodb|none|crc32)\""); SET GLOBAL innodb_checksum_algorithm = innodb; -SET GLOBAL innodb_default_encryption_key_id=1; +SET GLOBAL innodb_default_encryption_key_id=4; SET GLOBAL innodb_checksum_algorithm=crc32; create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb ROW_FORMAT=COMPRESSED encrypted=yes; diff --git a/mysql-test/suite/encryption/r/innodb-compressed-blob.result b/mysql-test/suite/encryption/r/innodb-compressed-blob.result index a6f4856fdbb..ce73b80820f 100644 --- a/mysql-test/suite/encryption/r/innodb-compressed-blob.result +++ b/mysql-test/suite/encryption/r/innodb-compressed-blob.result @@ -7,8 +7,6 @@ set GLOBAL innodb_default_encryption_key_id=4; create table t1(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed; create table t2(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes; create table t3(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=no; -Warnings: -Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 4 when encryption is disabled insert into t1 values (1, repeat('secret',6000)); insert into t2 values (1, repeat('secret',6000)); insert into t3 values (1, repeat('secret',6000)); diff --git a/mysql-test/suite/encryption/r/innodb-encryption-alter.result b/mysql-test/suite/encryption/r/innodb-encryption-alter.result index 381f14c9e9e..e1ff9eacfbe 100644 --- a/mysql-test/suite/encryption/r/innodb-encryption-alter.result +++ b/mysql-test/suite/encryption/r/innodb-encryption-alter.result @@ -4,7 +4,7 @@ SET GLOBAL innodb_encrypt_tables = ON; SET GLOBAL innodb_encryption_threads = 4; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4; Warnings: -Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 4 when encryption is disabled +Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID=4 when encryption is disabled DROP TABLE t1; set innodb_default_encryption_key_id = 99; ERROR 42000: Variable 'innodb_default_encryption_key_id' can't be set to the value of '99' @@ -44,6 +44,7 @@ t1 CREATE TABLE `t1` ( `c` varchar(256) DEFAULT NULL, PRIMARY KEY (`pk`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4 +set innodb_default_encryption_key_id = 1; CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1; ALTER TABLE t1 ENCRYPTION_KEY_ID=99; ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' @@ -51,7 +52,6 @@ SHOW WARNINGS; Level Code Message Warning 140 InnoDB: ENCRYPTION_KEY_ID 99 not available Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' -set innodb_default_encryption_key_id = 1; drop table t1,t2; SET GLOBAL innodb_encrypt_tables=OFF; CREATE TABLE t1 (a int not null primary key) engine=innodb; diff --git a/mysql-test/suite/encryption/r/innodb_encryption_default_key.result b/mysql-test/suite/encryption/r/innodb_encryption_default_key.result index 13754df0d8b..6ad1f621cb7 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption_default_key.result +++ b/mysql-test/suite/encryption/r/innodb_encryption_default_key.result @@ -1,15 +1,30 @@ -call mtr.add_suppression("InnoDB: cannot use encryption as default encryption key_id 999 not found from encryption plugin."); +call mtr.add_suppression("innodb_default_encryption_key_id=999 is unavailable in the encryption plugin"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; create table t1 (a int not null primary key) engine=InnoDB; create table t2 (a int not null primary key) encrypted=yes engine=InnoDB; +SET GLOBAL innodb_default_encryption_key_id = -1; +ERROR 42000: Variable 'innodb_default_encryption_key_id' can't be set to the value of '-1' +SHOW WARNINGS; +Level Code Message +Error 1231 Variable 'innodb_default_encryption_key_id' can't be set to the value of '-1' +SET GLOBAL innodb_default_encryption_key_id = 4294967296; +ERROR 42000: Variable 'innodb_default_encryption_key_id' can't be set to the value of '4294967296' +SHOW WARNINGS; +Level Code Message +Error 1231 Variable 'innodb_default_encryption_key_id' can't be set to the value of '4294967296' +SET GLOBAL innodb_default_encryption_key_id = 'k'; +ERROR 42000: Incorrect argument type to variable 'innodb_default_encryption_key_id' +SHOW WARNINGS; +Level Code Message +Error 1232 Incorrect argument type to variable 'innodb_default_encryption_key_id' SET GLOBAL innodb_default_encryption_key_id = 999; ERROR 42000: Variable 'innodb_default_encryption_key_id' can't be set to the value of '999' SHOW WARNINGS; Level Code Message -Warning 1210 InnoDB: innodb_default_encryption_key_id=999 not available in encryption plugin +Warning 1210 innodb_default_encryption_key_id=999 not available in the encryption plugin Error 1231 Variable 'innodb_default_encryption_key_id' can't be set to the value of '999' SET GLOBAL innodb_default_encryption_key_id = 4; SET GLOBAL innodb_encryption_threads = 4; diff --git a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test index 21ff07b5837..d0caed05006 100644 --- a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test +++ b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test @@ -16,11 +16,7 @@ SET GLOBAL innodb_encryption_threads = 4; call mtr.add_suppression("InnoDB: innodb_checksum_algorithm is set to \"strict_(crc32|none|innodb)\" but the page \\[page id: space=[0-9]+, page number=[0-9]+\\] contains a valid checksum \"(innodb|none|crc32)\""); SET GLOBAL innodb_checksum_algorithm = innodb; -# -# Need to use default encryption key_id as below creating tables -# with encrypted=no where nondefault key_id is not allowed. -# -SET GLOBAL innodb_default_encryption_key_id=1; +SET GLOBAL innodb_default_encryption_key_id=4; let MYSQLD_DATADIR =`SELECT @@datadir`; diff --git a/mysql-test/suite/encryption/t/innodb-encryption-alter.test b/mysql-test/suite/encryption/t/innodb-encryption-alter.test index d79bdecfc1a..fdd2dd86805 100644 --- a/mysql-test/suite/encryption/t/innodb-encryption-alter.test +++ b/mysql-test/suite/encryption/t/innodb-encryption-alter.test @@ -33,12 +33,11 @@ SHOW CREATE TABLE t1; DROP TABLE t1; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB; SHOW CREATE TABLE t1; +set innodb_default_encryption_key_id = 1; CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1; --error ER_ILLEGAL_HA_CREATE_OPTION ALTER TABLE t1 ENCRYPTION_KEY_ID=99; SHOW WARNINGS; -set innodb_default_encryption_key_id = 1; - --disable_warnings --disable_query_log diff --git a/mysql-test/suite/encryption/t/innodb_encryption_default_key.test b/mysql-test/suite/encryption/t/innodb_encryption_default_key.test index 61a9f973d20..0f077707f98 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption_default_key.test +++ b/mysql-test/suite/encryption/t/innodb_encryption_default_key.test @@ -2,7 +2,7 @@ -- source include/have_file_key_management_plugin.inc -- source include/not_embedded.inc -call mtr.add_suppression("InnoDB: cannot use encryption as default encryption key_id 999 not found from encryption plugin."); +call mtr.add_suppression("innodb_default_encryption_key_id=999 is unavailable in the encryption plugin"); call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); @@ -19,6 +19,19 @@ SET GLOBAL innodb_file_per_table = ON; create table t1 (a int not null primary key) engine=InnoDB; create table t2 (a int not null primary key) encrypted=yes engine=InnoDB; +# +# Test limits +# +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_encryption_key_id = -1; +SHOW WARNINGS; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_default_encryption_key_id = 4294967296; +SHOW WARNINGS; +--error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL innodb_default_encryption_key_id = 'k'; +SHOW WARNINGS; + # Do not allow setting default key to key_id that is not found --error ER_WRONG_VALUE_FOR_VAR SET GLOBAL innodb_default_encryption_key_id = 999; diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index c618a520b40..3e66bfee884 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1065,7 +1065,7 @@ fil_crypt_start_encrypting_space( /* 1 - create crypt data using default encryption key_id */ crypt_data = fil_space_create_crypt_data(FIL_ENCRYPTION_DEFAULT, - thd_default_encryption_key_id()); + innodb_default_encryption_key_id()); if (crypt_data == NULL) { mutex_exit(&fil_crypt_threads_mutex); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0d9beb452d9..a22a287ec67 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -706,7 +706,12 @@ innodb_default_encryption_key_id_validate( if (value->val_int(value, &key_id_buf)) { /* The value is NULL. That is invalid. */ - return(1); + return 1; + } + + if (key_id_buf < 1 || key_id_buf > UINT_MAX32) { + /* Out of range */ + return 1; } *reinterpret_cast<uint*>(save) = key_id = static_cast<uint>(key_id_buf); @@ -718,12 +723,12 @@ innodb_default_encryption_key_id_validate( push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, - "InnoDB: innodb_default_encryption_key_id=%u not available in encryption plugin", + "innodb_default_encryption_key_id=%u not available in the encryption plugin", key_id); - return (1); + return 1; } - return(0); + return 0; } static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG, @@ -732,10 +737,8 @@ static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG, NULL, FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0); -/** Get global default encryption key_id -@return key_id */ -UNIV_INTERN -uint thd_default_encryption_key_id(void) +/** @return innodb_default_encryption_key_id */ +UNIV_INTERN uint innodb_default_encryption_key_id() { return(THDVAR(NULL, default_encryption_key_id)); } @@ -3646,10 +3649,8 @@ innobase_init( key_id = THDVAR(NULL, default_encryption_key_id); if (key_id != FIL_DEFAULT_ENCRYPTION_KEY && !encryption_key_id_exists(key_id)) { - sql_print_error("InnoDB: cannot use encryption as " - " default encryption key_id %u" - " not found from encryption plugin.", - key_id); + sql_print_error("innodb_default_encryption_key_id=%u is " + "unavailable in the encryption plugin", key_id); goto error; } @@ -12009,11 +12010,11 @@ ha_innobase::check_table_options( /* Ignore nondefault key_id if encryption is set off */ if (encrypt == FIL_ENCRYPTION_OFF - && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) { + && options->encryption_key_id != THDVAR(thd, default_encryption_key_id)) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, - "InnoDB: Ignored ENCRYPTION_KEY_ID %u when encryption is disabled", + "InnoDB: Ignored ENCRYPTION_KEY_ID=%u when encryption is disabled", (uint)options->encryption_key_id ); options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY; diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 06610dcc94b..84d5652ce64 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -348,10 +348,8 @@ thd_supports_xa( THD* thd); /*!< in: thread handle, or NULL to query the global innodb_supports_xa */ -/** Get global default encryption key_id -@return key_id */ -UNIV_INTERN -uint thd_default_encryption_key_id(void); +/** @return innodb_default_encryption_key_id */ +UNIV_INTERN uint innodb_default_encryption_key_id(); /** Get status of innodb_tmpdir. @param[in] thd thread handle, or NULL to query diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index c618a520b40..3e66bfee884 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1065,7 +1065,7 @@ fil_crypt_start_encrypting_space( /* 1 - create crypt data using default encryption key_id */ crypt_data = fil_space_create_crypt_data(FIL_ENCRYPTION_DEFAULT, - thd_default_encryption_key_id()); + innodb_default_encryption_key_id()); if (crypt_data == NULL) { mutex_exit(&fil_crypt_threads_mutex); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 704e3478195..2fdd03fbb6e 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -707,7 +707,12 @@ innodb_default_encryption_key_id_validate( if (value->val_int(value, &key_id_buf)) { /* The value is NULL. That is invalid. */ - return(1); + return 1; + } + + if (key_id_buf < 1 || key_id_buf > UINT_MAX32) { + /* Out of range */ + return 1; } *reinterpret_cast<uint*>(save) = key_id = static_cast<uint>(key_id_buf); @@ -719,12 +724,12 @@ innodb_default_encryption_key_id_validate( push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, - "InnoDB: innodb_default_encryption_key_id=%u not available in encryption plugin", + "innodb_default_encryption_key_id=%u not available in the encryption plugin", key_id); - return (1); + return 1; } - return(0); + return 0; } static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG, @@ -733,10 +738,8 @@ static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG, NULL, FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0); -/** Get global default encryption key_id -@return key_id */ -UNIV_INTERN -uint thd_default_encryption_key_id(void) +/** @return innodb_default_encryption_key_id */ +UNIV_INTERN uint innodb_default_encryption_key_id() { return(THDVAR(NULL, default_encryption_key_id)); } @@ -4096,10 +4099,8 @@ innobase_init( key_id = THDVAR(NULL, default_encryption_key_id); if (key_id != FIL_DEFAULT_ENCRYPTION_KEY && !encryption_key_id_exists(key_id)) { - sql_print_error("InnoDB: cannot use encryption as " - " default encryption key_id %u" - " not found from encryption plugin.", - key_id); + sql_print_error("innodb_default_encryption_key_id=%u is " + "unavailable in the encryption plugin", key_id); goto error; } @@ -12576,11 +12577,11 @@ ha_innobase::check_table_options( /* Ignore nondefault key_id if encryption is set off */ if (encrypt == FIL_ENCRYPTION_OFF - && options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) { + && options->encryption_key_id != THDVAR(thd, default_encryption_key_id)) { push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, - "InnoDB: Ignored ENCRYPTION_KEY_ID %u when encryption is disabled", + "InnoDB: Ignored ENCRYPTION_KEY_ID=%u when encryption is disabled", (uint)options->encryption_key_id ); options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY; diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h index ef91484817a..60b36440a8b 100644 --- a/storage/xtradb/include/ha_prototypes.h +++ b/storage/xtradb/include/ha_prototypes.h @@ -366,10 +366,8 @@ thd_supports_xa( THD* thd); /*!< in: thread handle, or NULL to query the global innodb_supports_xa */ -/** Get global default encryption key_id -@return key_id */ -UNIV_INTERN -uint thd_default_encryption_key_id(void); +/** @return innodb_default_encryption_key_id */ +UNIV_INTERN uint innodb_default_encryption_key_id(); /** Get status of innodb_tmpdir. @param[in] thd thread handle, or NULL to query
participants (1)
-
jan