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

Default values of variables were not subject to upper/lower bounds
and step, while setting variables was. Bounds and step are also
applied to defaults now; defaults are corrected quietly, values
given by the user are corrected, and a correction-warning is thrown
as needed. Lastly, very large values could wrap around, starting
from 0 again. They are bounded at the maximum value for the
respective data-type now if no lower maximum is specified in the
variable's definition.
parent 6b92ec4a
...@@ -737,9 +737,9 @@ static struct my_option my_long_options[] = ...@@ -737,9 +737,9 @@ static struct my_option my_long_options[] =
0, 1}, 0, 1},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packet length to send to, or receive from server", "Max packet length to send to, or receive from server",
(gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG, (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0,
REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L, GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
MALLOC_OVERHEAD, 1024, 0}, (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"Buffer for TCP/IP and socket communication", "Buffer for TCP/IP and socket communication",
(gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG, (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG,
...@@ -747,12 +747,13 @@ static struct my_option my_long_options[] = ...@@ -747,12 +747,13 @@ static struct my_option my_long_options[] =
{"select_limit", OPT_SELECT_LIMIT, {"select_limit", OPT_SELECT_LIMIT,
"Automatic limit for SELECT when using --safe-updates", "Automatic limit for SELECT when using --safe-updates",
(gptr*) &select_limit, (gptr*) &select_limit,
(gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0}, (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
0, 1, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE, {"max_join_size", OPT_MAX_JOIN_SIZE,
"Automatic limit for rows in a join when using --safe-updates", "Automatic limit for rows in a join when using --safe-updates",
(gptr*) &max_join_size, (gptr*) &max_join_size,
(gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
0}, 0, 1, 0},
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth, " uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth,
(gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
......
...@@ -4986,7 +4986,7 @@ static struct my_option my_long_options[] = ...@@ -4986,7 +4986,7 @@ static struct my_option my_long_options[] =
"Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Sleep always this many seconds on sleep commands.", {"sleep", 'T', "Sleep always this many seconds on sleep commands.",
(gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0, (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
0, 0, 0}, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, (gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
......
...@@ -219,6 +219,7 @@ double my_strtod(const char *str, char **end, int *error); ...@@ -219,6 +219,7 @@ double my_strtod(const char *str, char **end, int *error);
double my_atof(const char *nptr); double my_atof(const char *nptr);
extern char *llstr(longlong value,char *buff); extern char *llstr(longlong value,char *buff);
extern char *ullstr(longlong value,char *buff);
#ifndef HAVE_STRTOUL #ifndef HAVE_STRTOUL
extern long strtol(const char *str, char **ptr, int base); extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base); extern ulong strtoul(const char *str, char **ptr, int base);
......
...@@ -67,7 +67,8 @@ extern void my_print_variables(const struct my_option *options); ...@@ -67,7 +67,8 @@ extern void my_print_variables(const struct my_option *options);
extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
const struct my_option *)); const struct my_option *));
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp); ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
bool *fixed);
my_bool getopt_compare_strings(const char *s, const char *t, uint length); my_bool getopt_compare_strings(const char *s, const char *t, uint length);
C_MODE_END C_MODE_END
......
...@@ -109,12 +109,20 @@ c1 ...@@ -109,12 +109,20 @@ c1
DROP TABLE t1; DROP TABLE t1;
SET @@auto_increment_offset= SET @@auto_increment_offset=
@bug20627_old_auto_increment_offset; @bug20627_old_auto_increment_offset;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@auto_increment_increment= SET @@auto_increment_increment=
@bug20627_old_auto_increment_increment; @bug20627_old_auto_increment_increment;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
SET @@session.auto_increment_offset= SET @@session.auto_increment_offset=
@bug20627_old_session_auto_increment_offset; @bug20627_old_session_auto_increment_offset;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@session.auto_increment_increment= SET @@session.auto_increment_increment=
@bug20627_old_session_auto_increment_increment; @bug20627_old_session_auto_increment_increment;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
SET @bug20830_old_auto_increment_offset= SET @bug20830_old_auto_increment_offset=
@@auto_increment_offset= 2; @@auto_increment_offset= 2;
SET @bug20830_old_auto_increment_increment= SET @bug20830_old_auto_increment_increment=
...@@ -237,12 +245,20 @@ SUM(c1) ...@@ -237,12 +245,20 @@ SUM(c1)
DROP TABLE t1; DROP TABLE t1;
SET @@auto_increment_offset= SET @@auto_increment_offset=
@bug20830_old_auto_increment_offset; @bug20830_old_auto_increment_offset;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@auto_increment_increment= SET @@auto_increment_increment=
@bug20830_old_auto_increment_increment; @bug20830_old_auto_increment_increment;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
SET @@session.auto_increment_offset= SET @@session.auto_increment_offset=
@bug20830_old_session_auto_increment_offset; @bug20830_old_session_auto_increment_offset;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@session.auto_increment_increment= SET @@session.auto_increment_increment=
@bug20830_old_session_auto_increment_increment; @bug20830_old_session_auto_increment_increment;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
CREATE TABLE t1(a BIT); CREATE TABLE t1(a BIT);
INSERT DELAYED INTO t1 VALUES(1); INSERT DELAYED INTO t1 VALUES(1);
FLUSH TABLE t1; FLUSH TABLE t1;
......
...@@ -340,6 +340,8 @@ create table t4 (a int); ...@@ -340,6 +340,8 @@ create table t4 (a int);
insert into t4 values (1),(4),(3); insert into t4 values (1),(4),(3);
set @save_join_buffer_size=@@join_buffer_size; set @save_join_buffer_size=@@join_buffer_size;
set join_buffer_size= 4000; set join_buffer_size= 4000;
Warnings:
Warning 1292 Truncated incorrect join_buffer_size value: '4000'
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
from t0 as A force index(i1,i2), t0 as B force index (i1,i2) from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
where (A.key1 < 500000 or A.key2 < 3) where (A.key1 < 500000 or A.key2 < 3)
......
...@@ -1833,6 +1833,8 @@ show variables like "innodb_thread_concurrency"; ...@@ -1833,6 +1833,8 @@ show variables like "innodb_thread_concurrency";
Variable_name Value Variable_name Value
innodb_thread_concurrency 8 innodb_thread_concurrency 8
set global innodb_thread_concurrency=1001; set global innodb_thread_concurrency=1001;
Warnings:
Warning 1292 Truncated incorrect innodb_thread_concurrency value: '1001'
show variables like "innodb_thread_concurrency"; show variables like "innodb_thread_concurrency";
Variable_name Value Variable_name Value
innodb_thread_concurrency 1000 innodb_thread_concurrency 1000
...@@ -1852,6 +1854,8 @@ show variables like "innodb_concurrency_tickets"; ...@@ -1852,6 +1854,8 @@ show variables like "innodb_concurrency_tickets";
Variable_name Value Variable_name Value
innodb_concurrency_tickets 1000 innodb_concurrency_tickets 1000
set global innodb_concurrency_tickets=0; set global innodb_concurrency_tickets=0;
Warnings:
Warning 1292 Truncated incorrect innodb_concurrency_tickets value: '0'
show variables like "innodb_concurrency_tickets"; show variables like "innodb_concurrency_tickets";
Variable_name Value Variable_name Value
innodb_concurrency_tickets 1 innodb_concurrency_tickets 1
......
...@@ -712,6 +712,8 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2; ...@@ -712,6 +712,8 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2;
UPDATE t2 SET c='2007-01-03'; UPDATE t2 SET c='2007-01-03';
INSERT INTO t1(b,c) SELECT b,c FROM t2; INSERT INTO t1(b,c) SELECT b,c FROM t2;
set @@sort_buffer_size=8192; set @@sort_buffer_size=8192;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '8192'
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
3072 3072
......
...@@ -276,6 +276,8 @@ Variable_name Value ...@@ -276,6 +276,8 @@ Variable_name Value
Key_blocks_unused KEY_BLOCKS_UNUSED Key_blocks_unused KEY_BLOCKS_UNUSED
set global keycache2.key_buffer_size=0; set global keycache2.key_buffer_size=0;
set global keycache3.key_buffer_size=100; set global keycache3.key_buffer_size=100;
Warnings:
Warning 1292 Truncated incorrect key_buffer_size value: '100'
set global keycache3.key_buffer_size=0; set global keycache3.key_buffer_size=0;
create table t1 (mytext text, FULLTEXT (mytext)); create table t1 (mytext text, FULLTEXT (mytext));
insert t1 values ('aaabbb'); insert t1 values ('aaabbb');
......
set global max_allowed_packet=100; set global max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set max_allowed_packet=100; set max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set global net_buffer_length=100; set global net_buffer_length=100;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100'
set net_buffer_length=100; set net_buffer_length=100;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100'
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
len len
1024 1024
......
...@@ -806,6 +806,8 @@ select @@max_prepared_stmt_count; ...@@ -806,6 +806,8 @@ select @@max_prepared_stmt_count;
@@max_prepared_stmt_count @@max_prepared_stmt_count
0 0
set global max_prepared_stmt_count=10000000000000000; set global max_prepared_stmt_count=10000000000000000;
Warnings:
Warning 1292 Truncated incorrect max_prepared_stmt_count value: '10000000000000000'
select @@max_prepared_stmt_count; select @@max_prepared_stmt_count;
@@max_prepared_stmt_count @@max_prepared_stmt_count
1048576 1048576
......
...@@ -3666,6 +3666,8 @@ CREATE TABLE t1 (a int, b int auto_increment, PRIMARY KEY (b)); ...@@ -3666,6 +3666,8 @@ CREATE TABLE t1 (a int, b int auto_increment, PRIMARY KEY (b));
CREATE TABLE t2 (x int auto_increment, y int, z int, CREATE TABLE t2 (x int auto_increment, y int, z int,
PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b)); PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b));
SET SESSION sort_buffer_size = 32 * 1024; SET SESSION sort_buffer_size = 32 * 1024;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '32768'
SELECT SQL_NO_CACHE COUNT(*) SELECT SQL_NO_CACHE COUNT(*)
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
FROM t1) t; FROM t1) t;
...@@ -4101,6 +4103,8 @@ INSERT INTO `t1` VALUES ('asdf','2007-02-08 01:11:26'); ...@@ -4101,6 +4103,8 @@ INSERT INTO `t1` VALUES ('asdf','2007-02-08 01:11:26');
INSERT INTO `t2` VALUES ('abcdefghijk'); INSERT INTO `t2` VALUES ('abcdefghijk');
INSERT INTO `t2` VALUES ('asdf'); INSERT INTO `t2` VALUES ('asdf');
SET session sort_buffer_size=8192; SET session sort_buffer_size=8192;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '8192'
SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2; SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2;
d1 d1
1 1
......
...@@ -269,6 +269,8 @@ a+0 b+0 ...@@ -269,6 +269,8 @@ a+0 b+0
56 379 56 379
68 454 68 454
set @@max_length_for_sort_data=0; set @@max_length_for_sort_data=0;
Warnings:
Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0 b+0 a+0 b+0
57 135 57 135
......
...@@ -269,6 +269,8 @@ a+0 b+0 ...@@ -269,6 +269,8 @@ a+0 b+0
56 379 56 379
68 454 68 454
set @@max_length_for_sort_data=0; set @@max_length_for_sort_data=0;
Warnings:
Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0 b+0 a+0 b+0
57 135 57 135
......
...@@ -214,6 +214,8 @@ net_read_timeout 600 ...@@ -214,6 +214,8 @@ net_read_timeout 600
net_retry_count 10 net_retry_count 10
net_write_timeout 500 net_write_timeout 500
set net_buffer_length=1; set net_buffer_length=1;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '1'
show variables like 'net_buffer_length'; show variables like 'net_buffer_length';
Variable_name Value Variable_name Value
net_buffer_length 1024 net_buffer_length 1024
...@@ -238,7 +240,7 @@ show variables like '%alloc%'; ...@@ -238,7 +240,7 @@ show variables like '%alloc%';
Variable_name Value Variable_name Value
query_alloc_block_size 8192 query_alloc_block_size 8192
query_prealloc_size 8192 query_prealloc_size 8192
range_alloc_block_size 2048 range_alloc_block_size 4096
transaction_alloc_block_size 8192 transaction_alloc_block_size 8192
transaction_prealloc_size 4096 transaction_prealloc_size 4096
set @@range_alloc_block_size=1024*16; set @@range_alloc_block_size=1024*16;
...@@ -263,7 +265,7 @@ show variables like '%alloc%'; ...@@ -263,7 +265,7 @@ show variables like '%alloc%';
Variable_name Value Variable_name Value
query_alloc_block_size 8192 query_alloc_block_size 8192
query_prealloc_size 8192 query_prealloc_size 8192
range_alloc_block_size 2048 range_alloc_block_size 4096
transaction_alloc_block_size 8192 transaction_alloc_block_size 8192
transaction_prealloc_size 4096 transaction_prealloc_size 4096
SELECT @@version LIKE 'non-existent'; SELECT @@version LIKE 'non-existent';
...@@ -321,6 +323,8 @@ select @@autocommit, @@big_tables; ...@@ -321,6 +323,8 @@ select @@autocommit, @@big_tables;
@@autocommit @@big_tables @@autocommit @@big_tables
1 1 1 1
set global binlog_cache_size=100; set global binlog_cache_size=100;
Warnings:
Warning 1292 Truncated incorrect binlog_cache_size value: '100'
set bulk_insert_buffer_size=100; set bulk_insert_buffer_size=100;
set character set cp1251_koi8; set character set cp1251_koi8;
set character set default; set character set default;
...@@ -349,17 +353,27 @@ set global flush_time=100; ...@@ -349,17 +353,27 @@ set global flush_time=100;
set insert_id=1; set insert_id=1;
set interactive_timeout=100; set interactive_timeout=100;
set join_buffer_size=100; set join_buffer_size=100;
Warnings:
Warning 1292 Truncated incorrect join_buffer_size value: '100'
set last_insert_id=1; set last_insert_id=1;
set global local_infile=1; set global local_infile=1;
set long_query_time=100; set long_query_time=100;
set low_priority_updates=1; set low_priority_updates=1;
set max_allowed_packet=100; set max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set global max_binlog_cache_size=100; set global max_binlog_cache_size=100;
Warnings:
Warning 1292 Truncated incorrect max_binlog_cache_size value: '100'
set global max_binlog_size=100; set global max_binlog_size=100;
Warnings:
Warning 1292 Truncated incorrect max_binlog_size value: '100'
set global max_connect_errors=100; set global max_connect_errors=100;
set global max_connections=100; set global max_connections=100;
set global max_delayed_threads=100; set global max_delayed_threads=100;
set max_heap_table_size=100; set max_heap_table_size=100;
Warnings:
Warning 1292 Truncated incorrect max_heap_table_size value: '100'
set max_join_size=100; set max_join_size=100;
set max_sort_length=100; set max_sort_length=100;
set max_tmp_tables=100; set max_tmp_tables=100;
...@@ -370,17 +384,25 @@ select @@max_user_connections; ...@@ -370,17 +384,25 @@ select @@max_user_connections;
set global max_write_lock_count=100; set global max_write_lock_count=100;
set myisam_sort_buffer_size=100; set myisam_sort_buffer_size=100;
set net_buffer_length=100; set net_buffer_length=100;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100'
set net_read_timeout=100; set net_read_timeout=100;
set net_write_timeout=100; set net_write_timeout=100;
set global query_cache_limit=100; set global query_cache_limit=100;
set global query_cache_size=100; set global query_cache_size=100;
set global query_cache_type=demand; set global query_cache_type=demand;
set read_buffer_size=100; set read_buffer_size=100;
Warnings:
Warning 1292 Truncated incorrect read_buffer_size value: '100'
set read_rnd_buffer_size=100; set read_rnd_buffer_size=100;
Warnings:
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '100'
set global rpl_recovery_rank=100; set global rpl_recovery_rank=100;
set global server_id=100; set global server_id=100;
set global slow_launch_time=100; set global slow_launch_time=100;
set sort_buffer_size=100; set sort_buffer_size=100;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '100'
set @@max_sp_recursion_depth=10; set @@max_sp_recursion_depth=10;
select @@max_sp_recursion_depth; select @@max_sp_recursion_depth;
@@max_sp_recursion_depth @@max_sp_recursion_depth
...@@ -420,6 +442,8 @@ set storage_engine=myisam; ...@@ -420,6 +442,8 @@ set storage_engine=myisam;
set global thread_cache_size=100; set global thread_cache_size=100;
set timestamp=1, timestamp=default; set timestamp=1, timestamp=default;
set tmp_table_size=100; set tmp_table_size=100;
Warnings:
Warning 1292 Truncated incorrect tmp_table_size value: '100'
set tx_isolation="READ-COMMITTED"; set tx_isolation="READ-COMMITTED";
set wait_timeout=100; set wait_timeout=100;
set log_warnings=1; set log_warnings=1;
...@@ -570,6 +594,8 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; ...@@ -570,6 +594,8 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value Variable_name Value
myisam_data_pointer_size 7 myisam_data_pointer_size 7
SET GLOBAL table_cache=-1; SET GLOBAL table_cache=-1;
Warnings:
Warning 1292 Truncated incorrect table_cache value: '0'
SHOW VARIABLES LIKE 'table_cache'; SHOW VARIABLES LIKE 'table_cache';
Variable_name Value Variable_name Value
table_cache 1 table_cache 1
......
...@@ -126,7 +126,7 @@ set GLOBAL query_cache_size=100000; ...@@ -126,7 +126,7 @@ set GLOBAL query_cache_size=100000;
set GLOBAL myisam_max_sort_file_size=2000000; set GLOBAL myisam_max_sort_file_size=2000000;
show global variables like 'myisam_max_sort_file_size'; show global variables like 'myisam_max_sort_file_size';
set GLOBAL myisam_max_sort_file_size=default; set GLOBAL myisam_max_sort_file_size=default;
--replace_result 2147483647 FILE_SIZE 9223372036854775807 FILE_SIZE --replace_result 2147482624 FILE_SIZE 2146435072 FILE_SIZE
show variables like 'myisam_max_sort_file_size'; show variables like 'myisam_max_sort_file_size';
set global net_retry_count=10, session net_retry_count=10; set global net_retry_count=10, session net_retry_count=10;
......
This diff is collapsed.
...@@ -186,7 +186,7 @@ MY_LOCALE *my_locale_by_number(uint number); ...@@ -186,7 +186,7 @@ MY_LOCALE *my_locale_by_number(uint number);
#define QUERY_ALLOC_PREALLOC_SIZE 8192 #define QUERY_ALLOC_PREALLOC_SIZE 8192
#define TRANS_ALLOC_BLOCK_SIZE 4096 #define TRANS_ALLOC_BLOCK_SIZE 4096
#define TRANS_ALLOC_PREALLOC_SIZE 4096 #define TRANS_ALLOC_PREALLOC_SIZE 4096
#define RANGE_ALLOC_BLOCK_SIZE 2048 #define RANGE_ALLOC_BLOCK_SIZE 4096
#define ACL_ALLOC_BLOCK_SIZE 1024 #define ACL_ALLOC_BLOCK_SIZE 1024
#define UDF_ALLOC_BLOCK_SIZE 1024 #define UDF_ALLOC_BLOCK_SIZE 1024
#define TABLE_ALLOC_BLOCK_SIZE 1024 #define TABLE_ALLOC_BLOCK_SIZE 1024
......
This diff is collapsed.
...@@ -113,6 +113,9 @@ static int check_max_delayed_threads(THD *thd, set_var *var); ...@@ -113,6 +113,9 @@ static int check_max_delayed_threads(THD *thd, set_var *var);
static void fix_thd_mem_root(THD *thd, enum_var_type type); static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type); static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type); static void fix_server_id(THD *thd, enum_var_type type);
static ulonglong fix_unsigned(THD *thd, ulonglong num,
const struct my_option *option_limits);
static void throw_bounds_warning(THD *thd, const char *name, ulonglong num);
static KEY_CACHE *create_key_cache(const char *name, uint length); static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type); void fix_sql_mode_var(THD *thd, enum_var_type type);
static byte *get_error_count(THD *thd); static byte *get_error_count(THD *thd);
...@@ -1448,6 +1451,27 @@ static void fix_server_id(THD *thd, enum_var_type type) ...@@ -1448,6 +1451,27 @@ static void fix_server_id(THD *thd, enum_var_type type)
} }
static void throw_bounds_warning(THD *thd, const char *name, ulonglong num)
{
char buf[22];
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
ER(ER_TRUNCATED_WRONG_VALUE), name,
ullstr(num, buf));
}
static ulonglong fix_unsigned(THD *thd, ulonglong num,
const struct my_option *option_limits)
{
bool fixed= FALSE;
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
if (fixed)
throw_bounds_warning(thd, option_limits->name, num);
return out;
}
sys_var_long_ptr:: sys_var_long_ptr::
sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg, sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg,
sys_after_update_func after_update_arg) sys_after_update_func after_update_arg)
...@@ -1468,9 +1492,20 @@ bool sys_var_long_ptr_global::update(THD *thd, set_var *var) ...@@ -1468,9 +1492,20 @@ bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
ulonglong tmp= var->save_result.ulonglong_value; ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(guard); pthread_mutex_lock(guard);
if (option_limits) if (option_limits)
*value= (ulong) getopt_ull_limit_value(tmp, option_limits); *value= (ulong) fix_unsigned(thd, tmp, option_limits);
else else
{
#if SIZEOF_LONG < SIZEOF_LONG_LONG
/* Avoid overflows on 32 bit systems */
if (tmp > (ulonglong) ~(ulong) 0)
{
tmp= ((ulonglong) ~(ulong) 0);
throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
}
#endif
*value= (ulong) tmp; *value= (ulong) tmp;
}
pthread_mutex_unlock(guard); pthread_mutex_unlock(guard);
return 0; return 0;
} }
...@@ -1489,7 +1524,7 @@ bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var) ...@@ -1489,7 +1524,7 @@ bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
ulonglong tmp= var->save_result.ulonglong_value; ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(&LOCK_global_system_variables); pthread_mutex_lock(&LOCK_global_system_variables);
if (option_limits) if (option_limits)
*value= (ulonglong) getopt_ull_limit_value(tmp, option_limits); *value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
else else
*value= (ulonglong) tmp; *value= (ulonglong) tmp;
pthread_mutex_unlock(&LOCK_global_system_variables); pthread_mutex_unlock(&LOCK_global_system_variables);
...@@ -1539,38 +1574,29 @@ bool sys_var_thd_ulong::check(THD *thd, set_var *var) ...@@ -1539,38 +1574,29 @@ bool sys_var_thd_ulong::check(THD *thd, set_var *var)
bool sys_var_thd_ulong::update(THD *thd, set_var *var) bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{ {
ulonglong tmp= var->save_result.ulonglong_value; ulonglong tmp= var->save_result.ulonglong_value;
char buf[22];
bool truncated= false;
/* Don't use bigger value than given with --maximum-variable-name=.. */ /* Don't use bigger value than given with --maximum-variable-name=.. */
if ((ulong) tmp > max_system_variables.*offset) if ((ulong) tmp > max_system_variables.*offset)
{ {
truncated= true; throw_bounds_warning(thd, name, tmp);
llstr(tmp, buf);
tmp= max_system_variables.*offset; tmp= max_system_variables.*offset;
} }
#if SIZEOF_LONG == 4 if (option_limits)
/* Avoid overflows on 32 bit systems */ tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
if (tmp > (ulonglong) ~(ulong) 0) #if SIZEOF_LONG < SIZEOF_LONG_LONG
else if (tmp > (ulonglong) ~(ulong) 0)
{ {
truncated= true;
llstr(tmp, buf);
tmp= ((ulonglong) ~(ulong) 0); tmp= ((ulonglong) ~(ulong) 0);
throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
} }
#endif #endif
if (truncated)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
ER(ER_TRUNCATED_WRONG_VALUE), name,
buf);
if (option_limits)
tmp= (ulong) getopt_ull_limit_value(tmp, option_limits);
if (var->type == OPT_GLOBAL) if (var->type == OPT_GLOBAL)
global_system_variables.*offset= (ulong) tmp; global_system_variables.*offset= (ulong) tmp;
else else
thd->variables.*offset= (ulong) tmp; thd->variables.*offset= (ulong) tmp;
return 0; return 0;
} }
...@@ -1605,7 +1631,7 @@ bool sys_var_thd_ha_rows::update(THD *thd, set_var *var) ...@@ -1605,7 +1631,7 @@ bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
tmp= max_system_variables.*offset; tmp= max_system_variables.*offset;
if (option_limits) if (option_limits)
tmp= (ha_rows) getopt_ull_limit_value(tmp, option_limits); tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
if (var->type == OPT_GLOBAL) if (var->type == OPT_GLOBAL)
{ {
/* Lock is needed to make things safe on 32 bit systems */ /* Lock is needed to make things safe on 32 bit systems */
...@@ -1649,7 +1675,7 @@ bool sys_var_thd_ulonglong::update(THD *thd, set_var *var) ...@@ -1649,7 +1675,7 @@ bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
tmp= max_system_variables.*offset; tmp= max_system_variables.*offset;
if (option_limits) if (option_limits)
tmp= getopt_ull_limit_value(tmp, option_limits); tmp= fix_unsigned(thd, tmp, option_limits);
if (var->type == OPT_GLOBAL) if (var->type == OPT_GLOBAL)
{ {
/* Lock is needed to make things safe on 32 bit systems */ /* Lock is needed to make things safe on 32 bit systems */
...@@ -2493,7 +2519,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) ...@@ -2493,7 +2519,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
} }
key_cache->param_buff_size= key_cache->param_buff_size=
(ulonglong) getopt_ull_limit_value(tmp, option_limits); (ulonglong) fix_unsigned(thd, tmp, option_limits);
/* If key cache didn't existed initialize it, else resize it */ /* If key cache didn't existed initialize it, else resize it */
key_cache->in_init= 1; key_cache->in_init= 1;
...@@ -2541,7 +2567,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var) ...@@ -2541,7 +2567,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
goto end; goto end;
*((ulong*) (((char*) key_cache) + offset))= *((ulong*) (((char*) key_cache) + offset))=
(ulong) getopt_ull_limit_value(tmp, option_limits); (ulong) fix_unsigned(thd, tmp, option_limits);
/* /*
Don't create a new key cache if it didn't exist Don't create a new key cache if it didn't exist
......
...@@ -32,3 +32,9 @@ char *llstr(longlong value,char *buff) ...@@ -32,3 +32,9 @@ char *llstr(longlong value,char *buff)
longlong10_to_str(value,buff,-10); longlong10_to_str(value,buff,-10);
return buff; return buff;
} }
char *ullstr(longlong value,char *buff)
{
longlong10_to_str(value,buff,10);
return buff;
}
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