Commit a7d03bf4 authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg

Bug#31177: Server variables can't be set to their current values

Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).

Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
parent d58db1c2
...@@ -86,6 +86,8 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ; ...@@ -86,6 +86,8 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ;
@@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228
1 1
SET @@global.read_buffer_size = 2147479553; SET @@global.read_buffer_size = 2147479553;
Warnings:
Warning 1292 Truncated incorrect read_buffer_size value: '2147479553'
SELECT @@global.read_buffer_size; SELECT @@global.read_buffer_size;
@@global.read_buffer_size @@global.read_buffer_size
2147479552 2147479552
...@@ -114,6 +116,8 @@ SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ; ...@@ -114,6 +116,8 @@ SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ;
SET @@session.read_buffer_size = 65530.34.; SET @@session.read_buffer_size = 65530.34.;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
SET @@session.read_buffer_size = 2147479553; SET @@session.read_buffer_size = 2147479553;
Warnings:
Warning 1292 Truncated incorrect read_buffer_size value: '2147479553'
SELECT @@session.read_buffer_size; SELECT @@session.read_buffer_size;
@@session.read_buffer_size @@session.read_buffer_size
2147479552 2147479552
......
...@@ -88,6 +88,8 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822 ...@@ -88,6 +88,8 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822
@@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228 @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228
1 1
SET @@global.read_rnd_buffer_size = 2147479553; SET @@global.read_rnd_buffer_size = 2147479553;
Warnings:
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '2147479553'
SELECT @@global.read_rnd_buffer_size; SELECT @@global.read_rnd_buffer_size;
@@global.read_rnd_buffer_size @@global.read_rnd_buffer_size
2147479552 2147479552
...@@ -116,6 +118,8 @@ SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8 ...@@ -116,6 +118,8 @@ SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8
SET @@session.read_rnd_buffer_size = 65530.34.; SET @@session.read_rnd_buffer_size = 65530.34.;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
SET @@session.read_rnd_buffer_size = 2147479553; SET @@session.read_rnd_buffer_size = 2147479553;
Warnings:
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '2147479553'
SELECT @@session.read_rnd_buffer_size; SELECT @@session.read_rnd_buffer_size;
@@session.read_rnd_buffer_size @@session.read_rnd_buffer_size
2147479552 2147479552
......
...@@ -976,24 +976,26 @@ static void init_one_value(const struct my_option *option, uchar* *variable, ...@@ -976,24 +976,26 @@ static void init_one_value(const struct my_option *option, uchar* *variable,
*((my_bool*) variable)= (my_bool) value; *((my_bool*) variable)= (my_bool) value;
break; break;
case GET_INT: case GET_INT:
*((int*) variable)= (int) value; *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL);
break; break;
case GET_UINT:
case GET_ENUM: case GET_ENUM:
*((uint*) variable)= (uint) value; *((uint*) variable)= (uint) value;
break; break;
case GET_UINT:
*((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL);
break;
case GET_LONG: case GET_LONG:
*((long*) variable)= (long) value; *((long*) variable)= (long) getopt_ll_limit_value((long) value, option, NULL);
break; break;
case GET_ULONG: case GET_ULONG:
*((ulong*) variable)= (ulong) value; *((ulong*) variable)= (ulong) getopt_ull_limit_value((ulong) value, option, NULL);
break; break;
case GET_LL: case GET_LL:
*((longlong*) variable)= (longlong) value; *((longlong*) variable)= (longlong) getopt_ll_limit_value((longlong) value, option, NULL);
break; break;
case GET_ULL: case GET_ULL:
case GET_SET: case GET_SET:
*((ulonglong*) variable)= (ulonglong) value; *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value((ulonglong) value, option, NULL);
break; break;
case GET_DOUBLE: case GET_DOUBLE:
*((double*) variable)= (double) value; *((double*) variable)= (double) value;
......
...@@ -6611,7 +6611,7 @@ The minimum value for this variable is 4096.", ...@@ -6611,7 +6611,7 @@ The minimum value for this variable is 4096.",
{"max_user_connections", OPT_MAX_USER_CONNECTIONS, {"max_user_connections", OPT_MAX_USER_CONNECTIONS,
"The maximum number of active connections for a single user (0 = no limit).", "The maximum number of active connections for a single user (0 = no limit).",
(uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT, (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT,
REQUIRED_ARG, 0, 1, UINT_MAX, 0, 1, 0}, REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0},
{"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
"After this many write locks, allow some read locks to run in between.", "After this many write locks, allow some read locks to run in between.",
(uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG, (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG,
......
...@@ -8249,7 +8249,7 @@ static MYSQL_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index, ...@@ -8249,7 +8249,7 @@ static MYSQL_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
static MYSQL_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size, static MYSQL_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.", "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
NULL, NULL, 1*1024*1024L, 512*1024L, ~0L, 1024); NULL, NULL, 1*1024*1024L, 512*1024L, LONG_MAX, 1024);
static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment, static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
...@@ -8289,7 +8289,7 @@ static MYSQL_SYSVAR_LONG(lock_wait_timeout, innobase_lock_wait_timeout, ...@@ -8289,7 +8289,7 @@ static MYSQL_SYSVAR_LONG(lock_wait_timeout, innobase_lock_wait_timeout,
static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size, static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The size of the buffer which InnoDB uses to write log to the log files on disk.", "The size of the buffer which InnoDB uses to write log to the log files on disk.",
NULL, NULL, 1024*1024L, 256*1024L, ~0L, 1024); NULL, NULL, 1024*1024L, 256*1024L, LONG_MAX, 1024);
static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size, static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
...@@ -8309,7 +8309,7 @@ static MYSQL_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups, ...@@ -8309,7 +8309,7 @@ static MYSQL_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
static MYSQL_SYSVAR_LONG(open_files, innobase_open_files, static MYSQL_SYSVAR_LONG(open_files, innobase_open_files,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"How many files at the maximum InnoDB keeps open at the same time.", "How many files at the maximum InnoDB keeps open at the same time.",
NULL, NULL, 300L, 10L, ~0L, 0); NULL, NULL, 300L, 10L, LONG_MAX, 0);
static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds, static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
......
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