32
36
#define EX_MYSQLERR 2
34
static DRIZZLE drizzle_connection, *sock = 0;
35
static bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
36
opt_compress = 0, opt_databases = 0, opt_fast = 0,
37
opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0,
38
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
39
tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0,
40
opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0,
42
static uint verbose = 0, opt_mysql_port=0;
38
static DRIZZLE drizzle_connection, *sock= 0;
39
static bool opt_alldbs= false, opt_check_only_changed= false,
40
opt_extended= false, opt_compress= false, opt_databases= false,
41
opt_fast= false, opt_medium_check= false, opt_quick= false,
42
opt_all_in_1= false, opt_silent= false, opt_auto_repair= false,
43
ignore_errors= false, tty_password= false, opt_frm= false,
44
debug_info_flag= false, debug_check_flag= false,
45
opt_fix_table_names= false, opt_fix_db_names= false,
46
opt_upgrade= false, opt_write_binlog= true;
47
static uint verbose= 0;
48
static uint32_t opt_drizzle_port= 0;
43
49
static int my_end_arg;
44
static char * opt_mysql_unix_port = 0;
45
static char *opt_password = 0, *current_user = 0,
46
*default_charset = (char *)DRIZZLE_DEFAULT_CHARSET_NAME,
48
static int first_error = 0;
50
static char * opt_drizzle_unix_port= NULL;
51
static char *opt_password= NULL, *current_user= NULL,
52
*default_charset= (char *)DRIZZLE_DEFAULT_CHARSET_NAME,
54
static int first_error= 0;
49
55
vector<string> tables4repair;
50
56
static uint opt_protocol=0;
51
57
static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
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
{"port", 'P', "Port number to use for connection or 0 for default to, in "
136
{"port", 'p', "Port number to use for connection or 0 for default to, in "
131
137
"order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
132
138
"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,
139
0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
136
140
{"protocol", OPT_DRIZZLE_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
137
141
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
145
149
{"silent", 's', "Print only error messages.", (char**) &opt_silent,
146
150
(char**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
147
151
{"socket", 'S', "Socket file to use for connection.",
148
(char**) &opt_mysql_unix_port, (char**) &opt_mysql_unix_port, 0, GET_STR,
152
(char**) &opt_drizzle_unix_port, (char**) &opt_drizzle_unix_port, 0, GET_STR,
149
153
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
150
154
{"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0,
151
155
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
254
261
default_charset= (char*) "utf8";
264
temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
265
/* if there is an alpha character this is not a valid port */
266
if (strlen(endchar) != 0)
268
fprintf(stderr, _("Non-integer value supplied for port. If you are trying to enter a password please use --password instead.\n"));
271
/* If the port number is > 65535 it is not a valid port
272
This also helps with potential data loss casting unsigned long to a
274
if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
276
fprintf(stderr, _("Value supplied for port is not valid.\n"));
281
opt_drizzle_port= (uint32_t) temp_drizzle_port;
259
char *start = argument;
287
char *start= argument;
260
288
if (opt_password)
261
289
free(opt_password);
262
290
opt_password = strdup(argument);
724
759
if (opt_protocol)
725
760
drizzle_options(&drizzle_connection,DRIZZLE_OPT_PROTOCOL,(char*)&opt_protocol);
726
761
if (!(sock = drizzle_connect(&drizzle_connection, host, user, passwd,
727
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
762
NULL, opt_drizzle_port, opt_drizzle_unix_port, 0)))
729
764
DBerror(&drizzle_connection, "when trying to connect");