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