1
/* Copyright (C) 2008 Drizzle development team
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/* By Jani Tolonen, 2001-04-20, MySQL, MYSQL Development Team */
18
#define CHECK_VERSION "2.5.0"
22
#include "client_priv.h"
23
#include <mystrings/m_ctype.h>
25
template class std::vector<std::string>;
33
static DRIZZLE drizzle_connection, *sock = 0;
34
static bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
35
opt_compress = 0, opt_databases = 0, opt_fast = 0,
36
opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0,
37
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
38
tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0,
39
opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0,
41
static uint verbose = 0, opt_mysql_port=0;
42
static int my_end_arg;
43
static char * opt_mysql_unix_port = 0;
44
static char *opt_password = 0, *current_user = 0,
45
*default_charset = (char *)DRIZZLE_DEFAULT_CHARSET_NAME,
47
static int first_error = 0;
48
vector<string> tables4repair;
49
static uint opt_protocol=0;
50
static const CHARSET_INFO *charset_info= &my_charset_latin1;
52
enum operations { DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
54
static struct my_option my_long_options[] =
56
{"all-databases", 'A',
57
"Check all the databases. This will be same as --databases with all databases selected.",
58
(char**) &opt_alldbs, (char**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
60
{"analyze", 'a', "Analyze given tables.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
63
"Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list.",
64
(char**) &opt_all_in_1, (char**) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0,
66
{"auto-repair", OPT_AUTO_REPAIR,
67
"If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.",
68
(char**) &opt_auto_repair, (char**) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0,
70
{"character-sets-dir", OPT_CHARSETS_DIR,
71
"Directory where character sets are.", (char**) &charsets_dir,
72
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
73
{"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
75
{"check-only-changed", 'C',
76
"Check only tables that have changed since last check or haven't been closed properly.",
77
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
78
{"check-upgrade", 'g',
79
"Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates.",
80
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
81
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
82
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
85
"To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.",
86
(char**) &opt_databases, (char**) &opt_databases, 0, GET_BOOL, NO_ARG,
88
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
89
(char**) &debug_check_flag, (char**) &debug_check_flag, 0,
90
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
91
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
92
(char**) &debug_info_flag, (char**) &debug_info_flag,
93
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
94
{"default-character-set", OPT_DEFAULT_CHARSET,
95
"Set the default character set.", (char**) &default_charset,
96
(char**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
97
{"fast",'F', "Check only tables that haven't been closed properly.",
98
(char**) &opt_fast, (char**) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
100
{"fix-db-names", OPT_FIX_DB_NAMES, "Fix database names.",
101
(char**) &opt_fix_db_names, (char**) &opt_fix_db_names,
102
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
103
{"fix-table-names", OPT_FIX_TABLE_NAMES, "Fix table names.",
104
(char**) &opt_fix_table_names, (char**) &opt_fix_table_names,
105
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
106
{"force", 'f', "Continue even if we get an sql-error.",
107
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
110
"If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting.",
111
(char**) &opt_extended, (char**) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0,
113
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
114
NO_ARG, 0, 0, 0, 0, 0, 0},
115
{"host",'h', "Connect to host.", (char**) ¤t_host,
116
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
117
{"medium-check", 'm',
118
"Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.",
119
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
120
{"write-binlog", OPT_WRITE_BINLOG,
121
"Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Use --skip-write-binlog when commands should not be sent to replication slaves.",
122
(char**) &opt_write_binlog, (char**) &opt_write_binlog, 0, GET_BOOL, NO_ARG,
124
{"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
127
"Password to use when connecting to server. If password is not given it's solicited on the tty.",
128
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
129
{"port", 'P', "Port number to use for connection or 0 for default to, in "
130
"order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
131
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
132
(char**) &opt_mysql_port,
133
(char**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
135
{"protocol", OPT_DRIZZLE_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
136
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
138
"If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.",
139
(char**) &opt_quick, (char**) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
142
"Can fix almost anything except unique keys that aren't unique.",
143
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
144
{"silent", 's', "Print only error messages.", (char**) &opt_silent,
145
(char**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
146
{"socket", 'S', "Socket file to use for connection.",
147
(char**) &opt_mysql_unix_port, (char**) &opt_mysql_unix_port, 0, GET_STR,
148
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
149
{"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0,
150
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
152
"When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
153
(char**) &opt_frm, (char**) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
155
#ifndef DONT_ALLOW_USER_CHANGE
156
{"user", 'u', "User for login if not current user.", (char**) ¤t_user,
157
(char**) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
159
{"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
160
NO_ARG, 0, 0, 0, 0, 0, 0},
161
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
162
NO_ARG, 0, 0, 0, 0, 0, 0},
163
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
166
static const char *load_default_groups[] = { "mysqlcheck", "client", 0 };
169
static void print_version(void);
170
static void usage(void);
171
static int get_options(int *argc, char ***argv);
172
static int process_all_databases(void);
173
static int process_databases(char **db_names);
174
static int process_selected_tables(char *db, char **table_names, int tables);
175
static int process_all_tables_in_db(char *database);
176
static int process_one_db(char *database);
177
static int use_db(char *database);
178
static int handle_request_for_tables(const char *tables, uint length);
179
static int dbConnect(char *host, char *user,char *passwd);
180
static void dbDisconnect(char *host);
181
static void DBerror(DRIZZLE *drizzle, const char *when);
182
static void safe_exit(int error);
183
static void print_result(void);
184
static uint fixed_name_length(const char *name);
185
static char *fix_table_name(char *dest, const char *src);
188
static void print_version(void)
190
printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, CHECK_VERSION,
191
drizzle_get_client_info(), SYSTEM_TYPE, MACHINE_TYPE);
192
} /* print_version */
194
static void usage(void)
197
puts("By Jani Tolonen, 2001-04-20, MySQL Development Team\n");
198
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n");
199
puts("and you are welcome to modify and redistribute it under the GPL license.\n");
200
puts("This program can be used to CHECK (-c,-m,-C), REPAIR (-r), ANALYZE (-a)");
201
puts("or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be");
202
puts("used at the same time. Not all options are supported by all storage engines.");
203
puts("Please consult the Drizzle manual for latest information about the");
204
puts("above. The options -c,-r,-a and -o are exclusive to each other, which");
205
puts("means that the last option will be used, if several was specified.\n");
206
puts("The option -c will be used by default, if none was specified. You");
207
puts("can change the default behavior by making a symbolic link, or");
208
puts("copying this file somewhere with another name, the alternatives are:");
209
puts("mysqlrepair: The default option will be -r");
210
puts("mysqlanalyze: The default option will be -a");
211
puts("mysqloptimize: The default option will be -o\n");
212
printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
213
printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
215
printf("OR %s [OPTIONS] --all-databases\n", my_progname);
216
print_defaults("my", load_default_groups);
217
my_print_help(my_long_options);
218
my_print_variables(my_long_options);
222
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
227
what_to_do = DO_ANALYZE;
230
what_to_do = DO_CHECK;
233
what_to_do = DO_CHECK;
234
opt_check_only_changed = 1;
236
case 'I': /* Fall through */
241
what_to_do = DO_CHECK;
242
opt_medium_check = 1;
245
what_to_do = DO_OPTIMIZE;
247
case OPT_FIX_DB_NAMES:
248
what_to_do= DO_UPGRADE;
249
default_charset= (char*) "utf8";
252
case OPT_FIX_TABLE_NAMES:
253
what_to_do= DO_UPGRADE;
254
default_charset= (char*) "utf8";
259
char *start = argument;
260
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
261
opt_password = my_strdup(argument, MYF(MY_FAE));
262
while (*argument) *argument++= 'x'; /* Destroy argument */
264
start[1] = 0; /* Cut length of argument */
271
what_to_do = DO_REPAIR;
274
what_to_do= DO_CHECK;
283
case 'V': print_version(); exit(0);
284
case OPT_DRIZZLE_PROTOCOL:
285
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
293
static int get_options(int *argc, char ***argv)
303
load_defaults("my", load_default_groups, argc, argv);
305
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
310
int pnlen = strlen(my_progname);
312
if (pnlen < 6) /* name too short */
313
what_to_do = DO_CHECK;
314
else if (!strcmp("repair", my_progname + pnlen - 6))
315
what_to_do = DO_REPAIR;
316
else if (!strcmp("analyze", my_progname + pnlen - 7))
317
what_to_do = DO_ANALYZE;
318
else if (!strcmp("optimize", my_progname + pnlen - 8))
319
what_to_do = DO_OPTIMIZE;
321
what_to_do = DO_CHECK;
324
/* TODO: This variable is not yet used */
325
if (strcmp(default_charset, charset_info->csname) &&
326
!(charset_info= get_charset_by_csname(default_charset,
327
MY_CS_PRIMARY, MYF(MY_WME))))
329
if (*argc > 0 && opt_alldbs)
331
printf("You should give only options, no arguments at all, with option\n");
332
printf("--all-databases. Please see %s --help for more information.\n",
336
if (*argc < 1 && !opt_alldbs)
338
printf("You forgot to give the arguments! Please see %s --help\n",
340
printf("for more information.\n");
344
opt_password = get_tty_password(NullS);
346
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
347
if (debug_check_flag)
348
my_end_arg= MY_CHECK_ERROR;
353
static int process_all_databases()
356
DRIZZLE_RES *tableres;
359
if (drizzle_query(sock, "SHOW DATABASES") ||
360
!(tableres = drizzle_store_result(sock)))
362
my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s",
363
MYF(0), drizzle_error(sock));
366
while ((row = drizzle_fetch_row(tableres)))
368
if (process_one_db(row[0]))
373
/* process_all_databases */
376
static int process_databases(char **db_names)
379
for ( ; *db_names ; db_names++)
381
if (process_one_db(*db_names))
385
} /* process_databases */
388
static int process_selected_tables(char *db, char **table_names, int tables)
395
We need table list in form `a`, `b`, `c`
396
that's why we need 2 more chars added to to each table name
397
space is for more readable output in logs and in case of error
399
char *table_names_comma_sep, *end;
400
int i, tot_length = 0;
402
for (i = 0; i < tables; i++)
403
tot_length+= fixed_name_length(*(table_names + i)) + 2;
405
if (!(table_names_comma_sep = (char *)
406
my_malloc((sizeof(char) * tot_length) + 4, MYF(MY_WME))))
409
for (end = table_names_comma_sep + 1; tables > 0;
410
tables--, table_names++)
412
end= fix_table_name(end, *table_names);
416
handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1);
417
my_free(table_names_comma_sep, MYF(0));
420
for (; tables > 0; tables--, table_names++)
421
handle_request_for_tables(*table_names, fixed_name_length(*table_names));
423
} /* process_selected_tables */
426
static uint fixed_name_length(const char *name)
429
uint extra_length= 2; /* count the first/last backticks */
431
for (p= name; *p; p++)
438
return (p - name) + extra_length;
442
static char *fix_table_name(char *dest, const char *src)
448
case '.': /* add backticks around '.' */
453
case '`': /* escape backtick character */
465
static int process_all_tables_in_db(char *database)
471
if (use_db(database))
473
if (drizzle_query(sock, "SHOW /*!50002 FULL*/ TABLES") ||
474
!((res= drizzle_store_result(sock))))
477
num_columns= drizzle_num_fields(res);
482
We need table list in form `a`, `b`, `c`
483
that's why we need 2 more chars added to to each table name
484
space is for more readable output in logs and in case of error
490
while ((row = drizzle_fetch_row(res)))
491
tot_length+= fixed_name_length(row[0]) + 2;
492
drizzle_data_seek(res, 0);
494
if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+4, MYF(MY_WME))))
496
drizzle_free_result(res);
499
for (end = tables + 1; (row = drizzle_fetch_row(res)) ;)
501
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
504
end= fix_table_name(end, row[0]);
509
handle_request_for_tables(tables + 1, tot_length - 1);
510
my_free(tables, MYF(0));
514
while ((row = drizzle_fetch_row(res)))
516
/* Skip views if we don't perform renaming. */
517
if ((what_to_do != DO_UPGRADE) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
520
handle_request_for_tables(row[0], fixed_name_length(row[0]));
523
drizzle_free_result(res);
525
} /* process_all_tables_in_db */
529
static int fix_table_storage_name(const char *name)
531
char qbuf[100 + NAME_LEN*4];
533
if (strncmp(name, "#mysql50#", 9))
535
sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
536
if (drizzle_query(sock, qbuf))
538
fprintf(stderr, "Failed to %s\n", qbuf);
539
fprintf(stderr, "Error: %s\n", drizzle_error(sock));
543
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
547
static int fix_database_storage_name(const char *name)
549
char qbuf[100 + NAME_LEN*4];
551
if (strncmp(name, "#mysql50#", 9))
553
sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
554
if (drizzle_query(sock, qbuf))
556
fprintf(stderr, "Failed to %s\n", qbuf);
557
fprintf(stderr, "Error: %s\n", drizzle_error(sock));
561
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
565
static int process_one_db(char *database)
567
if (what_to_do == DO_UPGRADE)
570
if (opt_fix_db_names && !strncmp(database,"#mysql50#", 9))
572
rc= fix_database_storage_name(database);
575
if (rc || !opt_fix_table_names)
578
return process_all_tables_in_db(database);
582
static int use_db(char *database)
584
if (drizzle_get_server_version(sock) >= 50003 &&
585
!my_strcasecmp(&my_charset_latin1, database, "information_schema"))
587
if (drizzle_select_db(sock, database))
589
DBerror(sock, "when selecting the database");
596
static int handle_request_for_tables(const char *tables, uint length)
598
char *query, *end, options[100], message[100];
599
uint query_length= 0;
604
switch (what_to_do) {
607
if (opt_quick) end = stpcpy(end, " QUICK");
608
if (opt_fast) end = stpcpy(end, " FAST");
609
if (opt_medium_check) end = stpcpy(end, " MEDIUM"); /* Default */
610
if (opt_extended) end = stpcpy(end, " EXTENDED");
611
if (opt_check_only_changed) end = stpcpy(end, " CHANGED");
612
if (opt_upgrade) end = stpcpy(end, " FOR UPGRADE");
615
op= (opt_write_binlog) ? "REPAIR" : "REPAIR NO_WRITE_TO_BINLOG";
616
if (opt_quick) end = stpcpy(end, " QUICK");
617
if (opt_extended) end = stpcpy(end, " EXTENDED");
618
if (opt_frm) end = stpcpy(end, " USE_FRM");
621
op= (opt_write_binlog) ? "ANALYZE" : "ANALYZE NO_WRITE_TO_BINLOG";
624
op= (opt_write_binlog) ? "OPTIMIZE" : "OPTIMIZE NO_WRITE_TO_BINLOG";
627
return fix_table_storage_name(tables);
630
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
634
/* No backticks here as we added them before */
635
query_length= sprintf(query, "%s TABLE %s %s", op, tables, options);
641
ptr= stpcpy(stpcpy(query, op), " TABLE ");
642
ptr= fix_table_name(ptr, tables);
643
ptr= strxmov(ptr, " ", options, NullS);
644
query_length= (uint) (ptr - query);
646
if (drizzle_real_query(sock, query, query_length))
648
sprintf(message, "when executing '%s TABLE ... %s'", op, options);
649
DBerror(sock, message);
653
my_free(query, MYF(0));
658
static void print_result()
662
char prev[NAME_LEN*2+2];
666
res = drizzle_use_result(sock);
669
for (i = 0; (row = drizzle_fetch_row(res)); i++)
671
int changed = strcmp(prev, row[0]);
672
bool status = !strcmp(row[2], "status");
677
if there was an error with the table, we have --auto-repair set,
678
and this isn't a repair op, then add the table to the tables4repair
681
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
683
tables4repair.push_back(string(prev));
688
if (status && changed)
689
printf("%-50s %s", row[0], row[3]);
690
else if (!status && changed)
692
printf("%s\n%-9s: %s", row[0], row[2], row[3]);
693
if (strcmp(row[2],"note"))
697
printf("%-9s: %s", row[2], row[3]);
698
stpcpy(prev, row[0]);
701
/* add the last table to be repaired to the list */
702
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
703
tables4repair.push_back(string(prev));
704
drizzle_free_result(res);
708
static int dbConnect(char *host, char *user, char *passwd)
713
fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost");
715
drizzle_create(&drizzle_connection);
717
drizzle_options(&drizzle_connection, DRIZZLE_OPT_COMPRESS, NullS);
719
drizzle_options(&drizzle_connection,DRIZZLE_OPT_PROTOCOL,(char*)&opt_protocol);
720
if (!(sock = drizzle_connect(&drizzle_connection, host, user, passwd,
721
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
723
DBerror(&drizzle_connection, "when trying to connect");
726
drizzle_connection.reconnect= 1;
731
static void dbDisconnect(char *host)
734
fprintf(stderr, "# Disconnecting from %s...\n", host ? host : "localhost");
739
static void DBerror(DRIZZLE *drizzle, const char *when)
741
my_printf_error(0,"Got error: %d: %s %s", MYF(0),
742
drizzle_errno(drizzle), drizzle_error(drizzle), when);
743
safe_exit(EX_MYSQLERR);
748
static void safe_exit(int error)
760
int main(int argc, char **argv)
764
** Check out the args
766
if (get_options(&argc, &argv))
771
if (dbConnect(current_host, current_user, opt_password))
776
tables4repair.reserve(64);
777
if (tables4repair.capacity() == 0)
786
process_all_databases();
787
/* Only one database and selected table(s) */
788
else if (argc > 1 && !opt_databases)
789
process_selected_tables(*argv, (argv + 1), (argc - 1));
790
/* One or more databases, all tables */
792
process_databases(argv);
796
if (!opt_silent && (tables4repair.size() > 0))
797
puts("\nRepairing tables");
798
what_to_do = DO_REPAIR;
799
vector<string>::iterator i;
800
for ( i= tables4repair.begin() ; i < tables4repair.end() ; i++)
802
const char *name= (*i).c_str();
803
handle_request_for_tables(name, fixed_name_length(name));
807
dbDisconnect(current_host);
808
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
810
return(first_error!=0);