Skip to content

Commit 31d4e58

Browse files
author
[email protected]/white.intern.koehntopp.de
committed
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.
1 parent 6b92ec4 commit 31d4e58

21 files changed

+307
-121
lines changed

client/mysql.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,22 +737,23 @@ static struct my_option my_long_options[] =
737737
0, 1},
738738
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
739739
"Max packet length to send to, or receive from server",
740-
(gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG,
741-
REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,
742-
MALLOC_OVERHEAD, 1024, 0},
740+
(gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0,
741+
GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
742+
(longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
743743
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
744744
"Buffer for TCP/IP and socket communication",
745745
(gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG,
746746
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
747747
{"select_limit", OPT_SELECT_LIMIT,
748748
"Automatic limit for SELECT when using --safe-updates",
749749
(gptr*) &select_limit,
750-
(gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
750+
(gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
751+
0, 1, 0},
751752
{"max_join_size", OPT_MAX_JOIN_SIZE,
752753
"Automatic limit for rows in a join when using --safe-updates",
753754
(gptr*) &max_join_size,
754-
(gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
755-
0},
755+
(gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
756+
0, 1, 0},
756757
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
757758
" uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth,
758759
(gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},

client/mysqltest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4986,7 +4986,7 @@ static struct my_option my_long_options[] =
49864986
"Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
49874987
0, 0, 0, 0, 0, 0},
49884988
{"sleep", 'T', "Sleep always this many seconds on sleep commands.",
4989-
(gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0,
4989+
(gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
49904990
0, 0, 0},
49914991
{"socket", 'S', "Socket file to use for connection.",
49924992
(gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,

include/m_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ double my_strtod(const char *str, char **end, int *error);
219219
double my_atof(const char *nptr);
220220

221221
extern char *llstr(longlong value,char *buff);
222+
extern char *ullstr(longlong value,char *buff);
222223
#ifndef HAVE_STRTOUL
223224
extern long strtol(const char *str, char **ptr, int base);
224225
extern ulong strtoul(const char *str, char **ptr, int base);

include/my_getopt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ extern void my_print_variables(const struct my_option *options);
6767
extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
6868
const struct my_option *));
6969

70-
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);
70+
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
71+
bool *fixed);
7172
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
7273

7374
C_MODE_END

mysql-test/r/delayed.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,20 @@ c1
109109
DROP TABLE t1;
110110
SET @@auto_increment_offset=
111111
@bug20627_old_auto_increment_offset;
112+
Warnings:
113+
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
112114
SET @@auto_increment_increment=
113115
@bug20627_old_auto_increment_increment;
116+
Warnings:
117+
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
114118
SET @@session.auto_increment_offset=
115119
@bug20627_old_session_auto_increment_offset;
120+
Warnings:
121+
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
116122
SET @@session.auto_increment_increment=
117123
@bug20627_old_session_auto_increment_increment;
124+
Warnings:
125+
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
118126
SET @bug20830_old_auto_increment_offset=
119127
@@auto_increment_offset= 2;
120128
SET @bug20830_old_auto_increment_increment=
@@ -237,12 +245,20 @@ SUM(c1)
237245
DROP TABLE t1;
238246
SET @@auto_increment_offset=
239247
@bug20830_old_auto_increment_offset;
248+
Warnings:
249+
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
240250
SET @@auto_increment_increment=
241251
@bug20830_old_auto_increment_increment;
252+
Warnings:
253+
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
242254
SET @@session.auto_increment_offset=
243255
@bug20830_old_session_auto_increment_offset;
256+
Warnings:
257+
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
244258
SET @@session.auto_increment_increment=
245259
@bug20830_old_session_auto_increment_increment;
260+
Warnings:
261+
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
246262
CREATE TABLE t1(a BIT);
247263
INSERT DELAYED INTO t1 VALUES(1);
248264
FLUSH TABLE t1;

mysql-test/r/index_merge.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ create table t4 (a int);
340340
insert into t4 values (1),(4),(3);
341341
set @save_join_buffer_size=@@join_buffer_size;
342342
set join_buffer_size= 4000;
343+
Warnings:
344+
Warning 1292 Truncated incorrect join_buffer_size value: '4000'
343345
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
344346
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
345347
where (A.key1 < 500000 or A.key2 < 3)

mysql-test/r/innodb.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,8 @@ show variables like "innodb_thread_concurrency";
18331833
Variable_name Value
18341834
innodb_thread_concurrency 8
18351835
set global innodb_thread_concurrency=1001;
1836+
Warnings:
1837+
Warning 1292 Truncated incorrect innodb_thread_concurrency value: '1001'
18361838
show variables like "innodb_thread_concurrency";
18371839
Variable_name Value
18381840
innodb_thread_concurrency 1000
@@ -1852,6 +1854,8 @@ show variables like "innodb_concurrency_tickets";
18521854
Variable_name Value
18531855
innodb_concurrency_tickets 1000
18541856
set global innodb_concurrency_tickets=0;
1857+
Warnings:
1858+
Warning 1292 Truncated incorrect innodb_concurrency_tickets value: '0'
18551859
show variables like "innodb_concurrency_tickets";
18561860
Variable_name Value
18571861
innodb_concurrency_tickets 1

mysql-test/r/innodb_mysql.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,8 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2;
712712
UPDATE t2 SET c='2007-01-03';
713713
INSERT INTO t1(b,c) SELECT b,c FROM t2;
714714
set @@sort_buffer_size=8192;
715+
Warnings:
716+
Warning 1292 Truncated incorrect sort_buffer_size value: '8192'
715717
SELECT COUNT(*) FROM t1;
716718
COUNT(*)
717719
3072

mysql-test/r/key_cache.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ Variable_name Value
276276
Key_blocks_unused KEY_BLOCKS_UNUSED
277277
set global keycache2.key_buffer_size=0;
278278
set global keycache3.key_buffer_size=100;
279+
Warnings:
280+
Warning 1292 Truncated incorrect key_buffer_size value: '100'
279281
set global keycache3.key_buffer_size=0;
280282
create table t1 (mytext text, FULLTEXT (mytext));
281283
insert t1 values ('aaabbb');

mysql-test/r/packet.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
set global max_allowed_packet=100;
2+
Warnings:
3+
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
24
set max_allowed_packet=100;
5+
Warnings:
6+
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
37
set global net_buffer_length=100;
8+
Warnings:
9+
Warning 1292 Truncated incorrect net_buffer_length value: '100'
410
set net_buffer_length=100;
11+
Warnings:
12+
Warning 1292 Truncated incorrect net_buffer_length value: '100'
513
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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