Skip to content

Commit 6adb077

Browse files
author
Alexey Botchkov
committed
Bug#35269 mysqlcheck behaves different depending on order of parameters
Issue an error if user specifies multiple commands to run. Also there was an unnoticed bug that DO_CHECK was actually 0 which lead to wrong actions in some cases. The mysqlcheck.test contained commands with the suspicious meaning for the above reason. Extra commands removed from there. per-file commands: client/mysqlcheck.c Bug#35269 mysqlcheck behaves different depending on order of parameters Drop with an error if multiple commands. mysql-test/r/mysqlcheck.result Bug#35269 mysqlcheck behaves different depending on order of parameters result completed. mysql-test/t/mysqlcheck.test Bug#35269 mysqlcheck behaves different depending on order of parameters testcase added. not-working commands removed from some mysqlcheck calls.
1 parent 96c9960 commit 6adb077

File tree

3 files changed

+95
-9
lines changed

3 files changed

+95
-9
lines changed

client/mysqlcheck.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static char *shared_memory_base_name=0;
4747
#endif
4848
static uint opt_protocol=0;
4949

50-
enum operations { DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
50+
enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
5151

5252
static struct my_option my_long_options[] =
5353
{
@@ -241,6 +241,8 @@ static my_bool
241241
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
242242
char *argument)
243243
{
244+
int orig_what_to_do= what_to_do;
245+
244246
switch(optid) {
245247
case 'a':
246248
what_to_do = DO_ANALYZE;
@@ -315,6 +317,13 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
315317
opt->name);
316318
break;
317319
}
320+
321+
if (orig_what_to_do && (what_to_do != orig_what_to_do))
322+
{
323+
fprintf(stderr, "Error: %s doesn't support multiple contradicting commands.\n",
324+
my_progname);
325+
return 1;
326+
}
318327
return 0;
319328
}
320329

mysql-test/r/mysqlcheck.result

+62-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mysql.db OK
88
mysql.event OK
99
mysql.func OK
1010
mysql.general_log
11-
note : The storage engine for the table doesn't support optimize
11+
note : The storage engine for the table doesn't support analyze
1212
mysql.help_category OK
1313
mysql.help_keyword OK
1414
mysql.help_relation OK
@@ -21,14 +21,16 @@ mysql.procs_priv OK
2121
mysql.proxy_priv OK
2222
mysql.servers OK
2323
mysql.slow_log
24-
note : The storage engine for the table doesn't support optimize
24+
note : The storage engine for the table doesn't support analyze
2525
mysql.tables_priv OK
2626
mysql.time_zone OK
2727
mysql.time_zone_leap_second OK
2828
mysql.time_zone_name OK
2929
mysql.time_zone_transition OK
3030
mysql.time_zone_transition_type OK
3131
mysql.user OK
32+
mtr.global_suppressions Table is already up to date
33+
mtr.test_suppressions Table is already up to date
3234
mysql.columns_priv OK
3335
mysql.db OK
3436
mysql.event OK
@@ -55,10 +57,64 @@ mysql.time_zone_name OK
5557
mysql.time_zone_transition OK
5658
mysql.time_zone_transition_type OK
5759
mysql.user OK
60+
mysql.columns_priv OK
61+
mysql.db OK
62+
mysql.event OK
63+
mysql.func OK
64+
mysql.general_log
65+
note : The storage engine for the table doesn't support analyze
66+
mysql.help_category OK
67+
mysql.help_keyword OK
68+
mysql.help_relation OK
69+
mysql.help_topic OK
70+
mysql.host OK
71+
mysql.ndb_binlog_index OK
72+
mysql.plugin OK
73+
mysql.proc OK
74+
mysql.procs_priv OK
75+
mysql.proxy_priv OK
76+
mysql.servers OK
77+
mysql.slow_log
78+
note : The storage engine for the table doesn't support analyze
79+
mysql.tables_priv OK
80+
mysql.time_zone OK
81+
mysql.time_zone_leap_second OK
82+
mysql.time_zone_name OK
83+
mysql.time_zone_transition OK
84+
mysql.time_zone_transition_type OK
85+
mysql.user OK
86+
mysql.columns_priv Table is already up to date
87+
mysql.db Table is already up to date
88+
mysql.event Table is already up to date
89+
mysql.func Table is already up to date
90+
mysql.general_log
91+
note : The storage engine for the table doesn't support optimize
92+
mysql.help_category Table is already up to date
93+
mysql.help_keyword Table is already up to date
94+
mysql.help_relation Table is already up to date
95+
mysql.help_topic Table is already up to date
96+
mysql.host Table is already up to date
97+
mysql.ndb_binlog_index Table is already up to date
98+
mysql.plugin Table is already up to date
99+
mysql.proc Table is already up to date
100+
mysql.procs_priv Table is already up to date
101+
mysql.proxy_priv Table is already up to date
102+
mysql.servers Table is already up to date
103+
mysql.slow_log
104+
note : The storage engine for the table doesn't support optimize
105+
mysql.tables_priv Table is already up to date
106+
mysql.time_zone Table is already up to date
107+
mysql.time_zone_leap_second Table is already up to date
108+
mysql.time_zone_name Table is already up to date
109+
mysql.time_zone_transition Table is already up to date
110+
mysql.time_zone_transition_type Table is already up to date
111+
mysql.user Table is already up to date
58112
create table t1 (a int);
59113
create view v1 as select * from t1;
60114
test.t1 OK
115+
test.t1 Table is already up to date
61116
test.t1 OK
117+
test.t1 Table is already up to date
62118
drop view v1;
63119
drop table t1;
64120
create table `t``1`(a int);
@@ -127,6 +183,7 @@ Tables_in_test
127183
t1
128184
#mysql50#v-1
129185
v1
186+
test.t1 OK
130187
show tables;
131188
Tables_in_test
132189
t1
@@ -200,3 +257,6 @@ Tables_in_test (t1-1)
200257
t1-1
201258
drop table `t1-1`;
202259
End of 5.1 tests
260+
#
261+
# Bug #35269: mysqlcheck behaves different depending on order of parameters
262+
#

mysql-test/t/mysqlcheck.test

+23-6
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,25 @@ drop database if exists client_test_db;
2323
# Bug #13783 mysqlcheck tries to optimize and analyze information_schema
2424
#
2525
--replace_result 'Table is already up to date' OK
26-
--exec $MYSQL_CHECK --all-databases --analyze --optimize
26+
--exec $MYSQL_CHECK --all-databases --analyze
27+
--exec $MYSQL_CHECK --all-databases --optimize
2728
--replace_result 'Table is already up to date' OK
28-
--exec $MYSQL_CHECK --analyze --optimize --databases test information_schema mysql
29-
--exec $MYSQL_CHECK --analyze --optimize information_schema schemata
29+
--exec $MYSQL_CHECK --analyze --databases test information_schema mysql
30+
--exec $MYSQL_CHECK --optimize --databases test information_schema mysql
31+
--exec $MYSQL_CHECK --analyze information_schema schemata
32+
--exec $MYSQL_CHECK --optimize information_schema schemata
3033

3134
#
3235
# Bug #16502: mysqlcheck tries to check views
3336
#
3437
create table t1 (a int);
3538
create view v1 as select * from t1;
3639
--replace_result 'Table is already up to date' OK
37-
--exec $MYSQL_CHECK --analyze --optimize --databases test
40+
--exec $MYSQL_CHECK --analyze --databases test
41+
--exec $MYSQL_CHECK --optimize --databases test
3842
--replace_result 'Table is already up to date' OK
39-
--exec $MYSQL_CHECK --all-in-1 --analyze --optimize --databases test
43+
--exec $MYSQL_CHECK --all-in-1 --analyze --databases test
44+
--exec $MYSQL_CHECK --all-in-1 --optimize --databases test
4045
drop view v1;
4146
drop table t1;
4247

@@ -113,7 +118,8 @@ show tables;
113118
let $MYSQLD_DATADIR= `select @@datadir`;
114119
--copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm
115120
show tables;
116-
--exec $MYSQL_CHECK --check-upgrade --fix-table-names --databases test
121+
--exec $MYSQL_CHECK --check-upgrade --databases test
122+
--exec $MYSQL_CHECK --fix-table-names --databases test
117123
show tables;
118124
drop view v1, `v-1`;
119125
drop table t1;
@@ -212,3 +218,14 @@ show tables like 't1-1';
212218
drop table `t1-1`;
213219

214220
--echo End of 5.1 tests
221+
222+
223+
--echo #
224+
--echo # Bug #35269: mysqlcheck behaves different depending on order of parameters
225+
--echo #
226+
227+
--error 13
228+
--exec $MYSQL_CHECK -a --fix-table-names test "#mysql50#t1-1"
229+
--error 1
230+
--exec $MYSQL_CHECK -aoc test "#mysql50#t1-1"
231+

0 commit comments

Comments
 (0)