Commit ea764f5f authored by Sergei Golubchik's avatar Sergei Golubchik

s/innodb_default_encryption_key/innodb_default_encryption_key_id/

and make it a session variable, not global, as any decent
default sysvar for a table attribute should be
parent 92ff5236
......@@ -7,7 +7,7 @@ create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_f
ERROR HY000: Can't create table `test`.`innodb_dynamic` (errno: 140 "Wrong create options")
create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic encryption='ON' encryption_key_id=33;
create table innodb_redundant(c1 bigint not null, b char(200)) engine=innodb row_format=redundant encryption='ON' encryption_key_id=4;
SET GLOBAL innodb_default_encryption_key = 5;
set innodb_default_encryption_key_id = 5;
create table innodb_defkey(c1 bigint not null, b char(200)) engine=innodb encryption='ON';
show create table innodb_defkey;
Table Create Table
......
......@@ -4,7 +4,6 @@
--disable_query_log
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
let $default_encryption_key = `SELECT @@innodb_default_encryption_key`;
--enable_query_log
SET GLOBAL innodb_file_format = `Barracuda`;
......@@ -18,7 +17,7 @@ create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_f
create table innodb_dynamic(c1 bigint not null, b char(200)) engine=innodb row_format=dynamic encryption='ON' encryption_key_id=33;
create table innodb_redundant(c1 bigint not null, b char(200)) engine=innodb row_format=redundant encryption='ON' encryption_key_id=4;
SET GLOBAL innodb_default_encryption_key = 5;
set innodb_default_encryption_key_id = 5;
create table innodb_defkey(c1 bigint not null, b char(200)) engine=innodb encryption='ON';
show create table innodb_defkey;
......@@ -162,5 +161,4 @@ drop table innodb_defkey;
--disable_query_log
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
EVAL SET GLOBAL innodb_default_encryption_key = $default_encryption_key;
--enable_query_log
......@@ -10,7 +10,7 @@ there should be *no* long test name listed below:
select distinct variable_name as `there should be *no* variables listed below:` from t2
left join t1 on variable_name=test_name where test_name is null;
there should be *no* variables listed below:
innodb_default_encryption_key
innodb_default_encryption_key_id
strict_password_validation
drop table t1;
drop table t2;
SET @start_global_value = @@global.innodb_default_encryption_key;
SELECT @start_global_value;
@start_global_value
1
Valid value 0-9
select @@global.innodb_default_encryption_key <= 9;
@@global.innodb_default_encryption_key <= 9
1
select @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
1
select @@session.innodb_default_encryption_key;
ERROR HY000: Variable 'innodb_default_encryption_key' is a GLOBAL variable
show global variables like 'innodb_default_encryption_key';
Variable_name Value
innodb_default_encryption_key 1
show session variables like 'innodb_default_encryption_key';
Variable_name Value
innodb_default_encryption_key 1
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
VARIABLE_NAME VARIABLE_VALUE
INNODB_DEFAULT_ENCRYPTION_KEY 1
select * from information_schema.session_variables where variable_name='innodb_default_encryption_key';
VARIABLE_NAME VARIABLE_VALUE
INNODB_DEFAULT_ENCRYPTION_KEY 1
set global innodb_default_encryption_key=2;
select @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
2
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
VARIABLE_NAME VARIABLE_VALUE
INNODB_DEFAULT_ENCRYPTION_KEY 2
select * from information_schema.session_variables where variable_name='innodb_default_encryption_key';
VARIABLE_NAME VARIABLE_VALUE
INNODB_DEFAULT_ENCRYPTION_KEY 2
set session innodb_default_encryption_key=4;
ERROR HY000: Variable 'innodb_default_encryption_key' is a GLOBAL variable and should be set with SET GLOBAL
set global innodb_default_encryption_key=1.1;
ERROR 42000: Incorrect argument type to variable 'innodb_default_encryption_key'
set global innodb_default_encryption_key=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_default_encryption_key'
set global innodb_default_encryption_key="foo";
ERROR 42000: Incorrect argument type to variable 'innodb_default_encryption_key'
set global innodb_default_encryption_key=10;
select @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
10
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
VARIABLE_NAME VARIABLE_VALUE
INNODB_DEFAULT_ENCRYPTION_KEY 10
set global innodb_default_encryption_key=-7;
Warnings:
Warning 1292 Truncated incorrect innodb_default_encryption_key value: '-7'
select @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
1
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
VARIABLE_NAME VARIABLE_VALUE
INNODB_DEFAULT_ENCRYPTION_KEY 1
set global innodb_default_encryption_key=1;
select @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
1
set global innodb_default_encryption_key=255;
select @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
255
SET @@global.innodb_default_encryption_key = @start_global_value;
SELECT @@global.innodb_default_encryption_key;
@@global.innodb_default_encryption_key
1
......@@ -579,12 +579,12 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_DEFAULT_ENCRYPTION_KEY
SESSION_VALUE NULL
VARIABLE_NAME INNODB_DEFAULT_ENCRYPTION_KEY_ID
SESSION_VALUE 1
GLOBAL_VALUE 1
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
VARIABLE_SCOPE SESSION
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Default encryption key id used for table encryption.
NUMERIC_MIN_VALUE 1
......
--source include/have_innodb.inc
SET @start_global_value = @@global.innodb_default_encryption_key;
SELECT @start_global_value;
#
# exists as global only
#
--echo Valid value 0-9
select @@global.innodb_default_encryption_key <= 9;
select @@global.innodb_default_encryption_key;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.innodb_default_encryption_key;
show global variables like 'innodb_default_encryption_key';
show session variables like 'innodb_default_encryption_key';
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
select * from information_schema.session_variables where variable_name='innodb_default_encryption_key';
#
# show that it's writable
#
set global innodb_default_encryption_key=2;
select @@global.innodb_default_encryption_key;
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
select * from information_schema.session_variables where variable_name='innodb_default_encryption_key';
--error ER_GLOBAL_VARIABLE
set session innodb_default_encryption_key=4;
#
# incorrect types
#
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_default_encryption_key=1.1;
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_default_encryption_key=1e1;
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_default_encryption_key="foo";
set global innodb_default_encryption_key=10;
select @@global.innodb_default_encryption_key;
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
set global innodb_default_encryption_key=-7;
select @@global.innodb_default_encryption_key;
select * from information_schema.global_variables where variable_name='innodb_default_encryption_key';
#
# min/max values
#
set global innodb_default_encryption_key=1;
select @@global.innodb_default_encryption_key;
set global innodb_default_encryption_key=255;
select @@global.innodb_default_encryption_key;
#
# cleanup
#
SET @@global.innodb_default_encryption_key = @start_global_value;
SELECT @@global.innodb_default_encryption_key;
......@@ -548,11 +548,9 @@ ib_cb_t innodb_api_cb[] = {
(ib_cb_t) ib_cursor_stmt_begin
};
static MYSQL_SYSVAR_UINT(default_encryption_key, srv_default_encryption_key,
PLUGIN_VAR_RQCMDARG,
static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG,
"Default encryption key id used for table encryption.",
NULL,
NULL,
NULL, NULL,
FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0);
/**
......@@ -576,7 +574,7 @@ ha_create_table_option innodb_table_option_list[]=
/* With this option the user can enable encryption for the table */
HA_TOPTION_ENUM("ENCRYPTION", encryption, "DEFAULT,ON,OFF", 0),
/* With this option the user defines the key identifier using for the encryption */
HA_TOPTION_SYSVAR("ENCRYPTION_KEY_ID", encryption_key_id, default_encryption_key),
HA_TOPTION_SYSVAR("ENCRYPTION_KEY_ID", encryption_key_id, default_encryption_key_id),
HA_TOPTION_END
};
......@@ -19417,8 +19415,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(scrub_log),
MYSQL_SYSVAR(scrub_log_speed),
MYSQL_SYSVAR(encrypt_log),
MYSQL_SYSVAR(default_encryption_key),
MYSQL_SYSVAR(default_encryption_key_id),
/* Scrubing feature */
MYSQL_SYSVAR(immediate_scrub_data_uncompressed),
MYSQL_SYSVAR(background_scrub_data_uncompressed),
......
......@@ -560,9 +560,6 @@ that semaphore times out in InnoDB */
#define DEFAULT_SRV_FATAL_SEMAPHORE_TIMEOUT 600
extern ulong srv_fatal_semaphore_wait_threshold;
/** Default encryption key used for tablespace encryption */
extern uint srv_default_encryption_key;
/** Enable semaphore request instrumentation */
extern my_bool srv_instrument_semaphores;
......
......@@ -523,9 +523,6 @@ thread ensures that we flush the log files at least once per
second. */
static time_t srv_last_log_flush_time;
/** Default encryption key used for tablespace encryption */
UNIV_INTERN uint srv_default_encryption_key = FIL_DEFAULT_ENCRYPTION_KEY;
/** Enable semaphore request instrumentation */
UNIV_INTERN my_bool srv_instrument_semaphores = FALSE;
......
......@@ -613,11 +613,9 @@ ib_cb_t innodb_api_cb[] = {
(ib_cb_t) ib_cursor_stmt_begin
};
static MYSQL_SYSVAR_UINT(default_encryption_key, srv_default_encryption_key,
PLUGIN_VAR_RQCMDARG,
static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG,
"Default encryption key id used for table encryption.",
NULL,
NULL,
NULL, NULL,
FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0);
/**
......@@ -641,7 +639,7 @@ ha_create_table_option innodb_table_option_list[]=
/* With this option the user can enable encryption for the table */
HA_TOPTION_ENUM("ENCRYPTION", encryption, "DEFAULT,ON,OFF", 0),
/* With this option the user defines the key identifier using for the encryption */
HA_TOPTION_SYSVAR("ENCRYPTION_KEY_ID", encryption_key_id, default_encryption_key),
HA_TOPTION_SYSVAR("ENCRYPTION_KEY_ID", encryption_key_id, default_encryption_key_id),
HA_TOPTION_END
};
......@@ -20638,7 +20636,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(scrub_log),
MYSQL_SYSVAR(scrub_log_speed),
MYSQL_SYSVAR(encrypt_log),
MYSQL_SYSVAR(default_encryption_key),
MYSQL_SYSVAR(default_encryption_key_id),
/* Scrubing feature */
MYSQL_SYSVAR(immediate_scrub_data_uncompressed),
MYSQL_SYSVAR(background_scrub_data_uncompressed),
......
......@@ -703,9 +703,6 @@ that semaphore times out in InnoDB */
#define DEFAULT_SRV_FATAL_SEMAPHORE_TIMEOUT 600
extern ulong srv_fatal_semaphore_wait_threshold;
/** Default encryption key used for tablespace encryption */
extern uint srv_default_encryption_key;
/** Enable semaphore request instrumentation */
extern my_bool srv_instrument_semaphores;
......
......@@ -670,9 +670,6 @@ thread ensures that we flush the log files at least once per
second. */
static time_t srv_last_log_flush_time;
/** Default encryption key used for tablespace encryption */
UNIV_INTERN uint srv_default_encryption_key = FIL_DEFAULT_ENCRYPTION_KEY;
/** Enable semaphore request instrumentation */
UNIV_INTERN my_bool srv_instrument_semaphores = FALSE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment