57
56
{"all-databases", 'A',
58
57
"Check all the databases. This will be same as --databases with all databases selected.",
59
(char**) &opt_alldbs, (char**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
58
(uchar**) &opt_alldbs, (uchar**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
61
60
{"analyze", 'a', "Analyze given tables.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
64
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.",
65
(char**) &opt_all_in_1, (char**) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0,
64
(uchar**) &opt_all_in_1, (uchar**) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0,
67
66
{"auto-repair", OPT_AUTO_REPAIR,
68
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.",
69
(char**) &opt_auto_repair, (char**) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0,
68
(uchar**) &opt_auto_repair, (uchar**) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0,
71
70
{"character-sets-dir", OPT_CHARSETS_DIR,
72
"Directory where character sets are.", (char**) &charsets_dir,
73
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
71
"Directory where character sets are.", (uchar**) &charsets_dir,
72
(uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
74
73
{"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
76
75
{"check-only-changed", 'C',
80
79
"Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates.",
81
80
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
82
81
{"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
83
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
82
(uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
86
85
"To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.",
87
(char**) &opt_databases, (char**) &opt_databases, 0, GET_BOOL, NO_ARG,
86
(uchar**) &opt_databases, (uchar**) &opt_databases, 0, GET_BOOL, NO_ARG,
89
{"debug", '#', "This is a non-debug version. Catch this and exit.",
90
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
92
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
93
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
89
95
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
90
(char**) &debug_check_flag, (char**) &debug_check_flag, 0,
96
(uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
91
97
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
92
98
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
93
(char**) &debug_info_flag, (char**) &debug_info_flag,
99
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
94
100
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
95
101
{"default-character-set", OPT_DEFAULT_CHARSET,
96
"Set the default character set.", (char**) &default_charset,
97
(char**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
102
"Set the default character set.", (uchar**) &default_charset,
103
(uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
98
104
{"fast",'F', "Check only tables that haven't been closed properly.",
99
(char**) &opt_fast, (char**) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
105
(uchar**) &opt_fast, (uchar**) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
101
107
{"fix-db-names", OPT_FIX_DB_NAMES, "Fix database names.",
102
(char**) &opt_fix_db_names, (char**) &opt_fix_db_names,
108
(uchar**) &opt_fix_db_names, (uchar**) &opt_fix_db_names,
103
109
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
104
110
{"fix-table-names", OPT_FIX_TABLE_NAMES, "Fix table names.",
105
(char**) &opt_fix_table_names, (char**) &opt_fix_table_names,
111
(uchar**) &opt_fix_table_names, (uchar**) &opt_fix_table_names,
106
112
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
107
113
{"force", 'f', "Continue even if we get an sql-error.",
108
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
114
(uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
110
116
{"extended", 'e',
111
117
"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.",
112
(char**) &opt_extended, (char**) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0,
118
(uchar**) &opt_extended, (uchar**) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0,
114
120
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
115
121
NO_ARG, 0, 0, 0, 0, 0, 0},
116
{"host",'h', "Connect to host.", (char**) ¤t_host,
117
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
122
{"host",'h', "Connect to host.", (uchar**) ¤t_host,
123
(uchar**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
118
124
{"medium-check", 'm',
119
125
"Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.",
120
126
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
121
127
{"write-binlog", OPT_WRITE_BINLOG,
122
128
"Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Use --skip-write-binlog when commands should not be sent to replication slaves.",
123
(char**) &opt_write_binlog, (char**) &opt_write_binlog, 0, GET_BOOL, NO_ARG,
129
(uchar**) &opt_write_binlog, (uchar**) &opt_write_binlog, 0, GET_BOOL, NO_ARG,
124
130
1, 0, 0, 0, 0, 0},
125
131
{"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
128
134
"Password to use when connecting to server. If password is not given it's solicited on the tty.",
129
135
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
130
136
{"port", 'P', "Port number to use for connection or 0 for default to, in "
131
"order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
132
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
133
(char**) &opt_mysql_port,
134
(char**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
137
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
138
#if MYSQL_PORT_DEFAULT == 0
141
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
142
(uchar**) &opt_mysql_port,
143
(uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
136
{"protocol", OPT_DRIZZLE_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
145
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
137
146
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
139
148
"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.",
140
(char**) &opt_quick, (char**) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
149
(uchar**) &opt_quick, (uchar**) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
143
152
"Can fix almost anything except unique keys that aren't unique.",
144
153
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
145
{"silent", 's', "Print only error messages.", (char**) &opt_silent,
146
(char**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
155
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
156
"Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
157
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
159
{"silent", 's', "Print only error messages.", (uchar**) &opt_silent,
160
(uchar**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
147
161
{"socket", 'S', "Socket file to use for connection.",
148
(char**) &opt_mysql_unix_port, (char**) &opt_mysql_unix_port, 0, GET_STR,
162
(uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR,
149
163
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
150
164
{"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0,
151
165
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
152
166
{"use-frm", OPT_FRM,
153
167
"When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
154
(char**) &opt_frm, (char**) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
168
(uchar**) &opt_frm, (uchar**) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
156
170
#ifndef DONT_ALLOW_USER_CHANGE
157
{"user", 'u', "User for login if not current user.", (char**) ¤t_user,
158
(char**) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
171
{"user", 'u', "User for login if not current user.", (uchar**) ¤t_user,
172
(uchar**) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
160
174
{"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
161
175
NO_ARG, 0, 0, 0, 0, 0, 0},
691
717
printf("%s\n%-9s: %s", row[0], row[2], row[3]);
692
718
if (strcmp(row[2],"note"))
696
722
printf("%-9s: %s", row[2], row[3]);
697
my_stpcpy(prev, row[0]);
723
strmov(prev, row[0]);
700
726
/* add the last table to be repaired to the list */
701
727
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
702
tables4repair.push_back(string(prev));
703
drizzle_free_result(res);
728
insert_dynamic(&tables4repair, (uchar*) prev);
729
mysql_free_result(res);
707
733
static int dbConnect(char *host, char *user, char *passwd)
735
DBUG_ENTER("dbConnect");
712
738
fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost");
714
drizzle_create(&drizzle_connection);
740
mysql_init(&mysql_connection);
715
741
if (opt_compress)
716
drizzle_options(&drizzle_connection, DRIZZLE_OPT_COMPRESS, NULL);
742
mysql_options(&mysql_connection, MYSQL_OPT_COMPRESS, NullS);
717
743
if (opt_protocol)
718
drizzle_options(&drizzle_connection,DRIZZLE_OPT_PROTOCOL,(char*)&opt_protocol);
719
if (!(sock = drizzle_connect(&drizzle_connection, host, user, passwd,
744
mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
746
if (shared_memory_base_name)
747
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
749
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
720
750
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
722
DBerror(&drizzle_connection, "when trying to connect");
752
DBerror(&mysql_connection, "when trying to connect");
725
drizzle_connection.reconnect= 1;
755
mysql_connection.reconnect= 1;
727
757
} /* dbConnect */