210
191
static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
211
192
/* The names of functions that actually do the manipulation. */
212
193
static int get_options(int argc,char **argv);
213
bool get_one_option(int optid, const struct my_option *opt,
215
static int com_quit(string *str,const char*),
216
com_go(string *str,const char*), com_ego(string *str,const char*),
217
com_print(string *str,const char*),
218
com_help(string *str,const char*), com_clear(string *str,const char*),
219
com_connect(string *str,const char*), com_status(string *str,const char*),
220
com_use(string *str,const char*), com_source(string *str, const char*),
221
com_rehash(string *str, const char*), com_tee(string *str, const char*),
222
com_notee(string *str, const char*),
223
com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
224
com_warnings(string *str, const char*), com_nowarnings(string *str, const char*),
225
com_nopager(string *str, const char*), com_pager(string *str, const char*);
194
extern "C" my_bool get_one_option(int optid, const struct my_option *opt,
196
static int com_quit(String *str,char*),
197
com_go(String *str,char*), com_ego(String *str,char*),
198
com_print(String *str,char*),
199
com_help(String *str,char*), com_clear(String *str,char*),
200
com_connect(String *str,char*), com_status(String *str,char*),
201
com_use(String *str,char*), com_source(String *str, char*),
202
com_rehash(String *str, char*), com_tee(String *str, char*),
203
com_notee(String *str, char*), com_charset(String *str,char*),
204
com_prompt(String *str, char*), com_delimiter(String *str, char*),
205
com_warnings(String *str, char*), com_nowarnings(String *str, char*);
208
static int com_nopager(String *str, char*), com_pager(String *str, char*),
209
com_edit(String *str,char*), com_shell(String *str, char *);
227
212
static int read_and_execute(bool interactive);
228
213
static int sql_connect(char *host,char *database,char *user,char *password,
230
static const char *server_version_string(DRIZZLE *drizzle);
231
static int put_info(const char *str,INFO_TYPE info,uint error,
232
const char *sql_state);
233
static int put_error(DRIZZLE *drizzle);
234
static void safe_put_field(const char *pos,uint32_t length);
235
static void init_pager(void);
236
static void end_pager(void);
215
static const char *server_version_string(MYSQL *mysql);
216
static int put_info(const char *str,INFO_TYPE info,uint error=0,
217
const char *sql_state=0);
218
static int put_error(MYSQL *mysql);
219
static void safe_put_field(const char *pos,ulong length);
220
static void xmlencode_print(const char *src, uint length);
221
static void init_pager();
222
static void end_pager();
237
223
static void init_tee(const char *);
238
static void end_tee(void);
239
static const char* construct_prompt(void);
240
static char *get_arg(char *line, bool get_next_arg);
241
static void init_username(void);
224
static void end_tee();
225
static const char* construct_prompt();
226
static char *get_arg(char *line, my_bool get_next_arg);
227
static void init_username();
242
228
static void add_int_to_prompt(int toadd);
243
static int get_result_width(DRIZZLE_RES *res);
244
static int get_field_disp_length(DRIZZLE_FIELD * field);
245
static const char * strcont(register const char *str, register const char *set);
229
static int get_result_width(MYSQL_RES *res);
230
static int get_field_disp_length(MYSQL_FIELD * field);
247
232
/* A structure which contains information on the commands this program
248
233
can understand. */
250
const char *name; /* User printable name of the function. */
251
char cmd_char; /* msql command character */
252
int (*func)(string *str,const char *); /* Function to call to do the job. */
253
bool takes_params; /* Max parameters for command */
254
const char *doc; /* Documentation for this function. */
236
const char *name; /* User printable name of the function. */
237
char cmd_char; /* msql command character */
238
int (*func)(String *str,char *); /* Function to call to do the job. */
239
bool takes_params; /* Max parameters for command */
240
const char *doc; /* Documentation for this function. */
258
243
static COMMANDS commands[] = {
259
{ "?", '?', com_help, 1, N_("Synonym for `help'.") },
260
{ "clear", 'c', com_clear, 0, N_("Clear command.")},
244
{ "?", '?', com_help, 1, "Synonym for `help'." },
245
{ "clear", 'c', com_clear, 0, "Clear command."},
261
246
{ "connect",'r', com_connect,1,
262
N_("Reconnect to the server. Optional arguments are db and host." }),
247
"Reconnect to the server. Optional arguments are db and host." },
263
248
{ "delimiter", 'd', com_delimiter, 1,
264
N_("Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.") },
249
"Set statement delimiter. NOTE: Takes the rest of the line as new delimiter." },
251
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
265
253
{ "ego", 'G', com_ego, 0,
266
N_("Send command to drizzle server, display result vertically.")},
267
{ "exit", 'q', com_quit, 0, N_("Exit drizzle. Same as quit.")},
268
{ "go", 'g', com_go, 0, N_("Send command to drizzle server.") },
269
{ "help", 'h', com_help, 1, N_("Display this help.") },
270
{ "nopager",'n', com_nopager,0, N_("Disable pager, print to stdout.") },
271
{ "notee", 't', com_notee, 0, N_("Don't write into outfile.") },
272
{ "pager", 'P', com_pager, 1,
273
N_("Set PAGER [to_pager]. Print the query results via PAGER.") },
274
{ "print", 'p', com_print, 0, N_("Print current command.") },
275
{ "prompt", 'R', com_prompt, 1, N_("Change your drizzle prompt.")},
276
{ "quit", 'q', com_quit, 0, N_("Quit drizzle.") },
277
{ "rehash", '#', com_rehash, 0, N_("Rebuild completion hash.") },
254
"Send command to mysql server, display result vertically."},
255
{ "exit", 'q', com_quit, 0, "Exit mysql. Same as quit."},
256
{ "go", 'g', com_go, 0, "Send command to mysql server." },
257
{ "help", 'h', com_help, 1, "Display this help." },
259
{ "nopager",'n', com_nopager,0, "Disable pager, print to stdout." },
261
{ "notee", 't', com_notee, 0, "Don't write into outfile." },
263
{ "pager", 'P', com_pager, 1,
264
"Set PAGER [to_pager]. Print the query results via PAGER." },
266
{ "print", 'p', com_print, 0, "Print current command." },
267
{ "prompt", 'R', com_prompt, 1, "Change your mysql prompt."},
268
{ "quit", 'q', com_quit, 0, "Quit mysql." },
269
{ "rehash", '#', com_rehash, 0, "Rebuild completion hash." },
278
270
{ "source", '.', com_source, 1,
279
N_("Execute an SQL script file. Takes a file name as an argument.")},
280
{ "status", 's', com_status, 0, N_("Get status information from the server.")},
281
{ "tee", 'T', com_tee, 1,
282
N_("Set outfile [to_outfile]. Append everything into given outfile.") },
271
"Execute an SQL script file. Takes a file name as an argument."},
272
{ "status", 's', com_status, 0, "Get status information from the server."},
274
{ "system", '!', com_shell, 1, "Execute a system shell command."},
276
{ "tee", 'T', com_tee, 1,
277
"Set outfile [to_outfile]. Append everything into given outfile." },
283
278
{ "use", 'u', com_use, 1,
284
N_("Use another database. Takes database name as argument.") },
279
"Use another database. Takes database name as argument." },
280
{ "charset", 'C', com_charset, 1,
281
"Switch to another charset. Might be needed for processing binlog with multi-byte charsets." },
285
282
{ "warnings", 'W', com_warnings, 0,
286
N_("Show warnings after every statement.") },
283
"Show warnings after every statement." },
287
284
{ "nowarning", 'w', com_nowarnings, 0,
288
N_("Don't show warnings after every statement.") },
285
"Don't show warnings after every statement." },
289
286
/* Get bash-like expansion for some commands */
290
287
{ "create table", 0, 0, 0, ""},
291
288
{ "create database", 0, 0, 0, ""},
1265
1310
static struct my_option my_long_options[] =
1267
{"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1312
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1268
1313
0, 0, 0, 0, 0},
1269
{"help", 'I', N_("Synonym for -?"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1314
{"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1270
1315
0, 0, 0, 0, 0},
1271
1316
{"auto-rehash", OPT_AUTO_REHASH,
1272
N_("Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash."),
1273
(char**) &opt_rehash, (char**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1317
"Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.",
1318
(uchar**) &opt_rehash, (uchar**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1275
1320
{"no-auto-rehash", 'A',
1276
N_("No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of DRIZZLE and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead."),
1321
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
1277
1322
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1278
{"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
1279
N_("Automatically switch to vertical output mode if the result is wider than the terminal width."),
1280
(char**) &auto_vertical_output, (char**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1323
{"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
1324
"Automatically switch to vertical output mode if the result is wider than the terminal width.",
1325
(uchar**) &auto_vertical_output, (uchar**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1282
N_("Don't use history file. Disable interactive behavior. (Enables --silent)"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1327
"Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1283
1328
{"character-sets-dir", OPT_CHARSETS_DIR,
1284
N_("Directory where character sets are."), (char**) &charsets_dir,
1285
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1286
{"column-type-info", OPT_COLUMN_TYPES, N_("Display column type information."),
1287
(char**) &column_types_flag, (char**) &column_types_flag,
1288
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1289
{"comments", 'c', N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"),
1290
(char**) &preserve_comments, (char**) &preserve_comments,
1291
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1292
{"compress", 'C', N_("Use compression in server/client protocol."),
1293
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1329
"Directory where character sets are.", (uchar**) &charsets_dir,
1330
(uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1331
{"column-type-info", OPT_COLUMN_TYPES, "Display column type information.",
1332
(uchar**) &column_types_flag, (uchar**) &column_types_flag,
1333
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1334
{"comments", 'c', "Preserve comments. Send comments to the server."
1335
" The default is --skip-comments (discard comments), enable with --comments",
1336
(uchar**) &preserve_comments, (uchar**) &preserve_comments,
1337
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1338
{"compress", 'C', "Use compression in server/client protocol.",
1339
(uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1295
{"debug-check", OPT_DEBUG_CHECK, N_("Check memory and open file usage at exit ."),
1296
(char**) &debug_check_flag, (char**) &debug_check_flag, 0,
1343
{"debug", '#', "This is a non-debug version. Catch this and exit",
1344
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
1346
{"debug", '#', "Output debug log", (uchar**) &default_dbug_option,
1347
(uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1349
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
1350
(uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
1297
1351
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1298
{"debug-info", 'T', N_("Print some debug info at exit."), (char**) &debug_info_flag,
1299
(char**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1300
{"database", 'D', N_("Database to use."), (char**) ¤t_db,
1301
(char**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1352
{"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag,
1353
(uchar**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1354
{"database", 'D', "Database to use.", (uchar**) ¤t_db,
1355
(uchar**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1302
1356
{"default-character-set", OPT_DEFAULT_CHARSET,
1303
N_("(not used)"), 0,
1304
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1305
{"delimiter", OPT_DELIMITER, N_("Delimiter to be used."), (char**) &delimiter_str,
1306
(char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1307
{"execute", 'e', N_("Execute command and quit. (Disables --force and history file)"), 0,
1308
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1309
{"vertical", 'E', N_("Print the output of a query (rows) vertically."),
1310
(char**) &vertical, (char**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1357
"Set the default character set.", (uchar**) &default_charset,
1358
(uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1359
{"delimiter", OPT_DELIMITER, "Delimiter to be used.", (uchar**) &delimiter_str,
1360
(uchar**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1361
{"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0,
1362
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1363
{"vertical", 'E', "Print the output of a query (rows) vertically.",
1364
(uchar**) &vertical, (uchar**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1312
{"force", 'f', N_("Continue even if we get an sql error."),
1313
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1366
{"force", 'f', "Continue even if we get an sql error.",
1367
(uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1315
1369
{"named-commands", 'G',
1316
N_("Enable named commands. Named commands mean this program's internal commands; see drizzle> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default."),
1317
(char**) &named_cmds, (char**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1370
"Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.",
1371
(uchar**) &named_cmds, (uchar**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1319
1373
{"no-named-commands", 'g',
1320
N_("Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead."),
1374
"Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.",
1321
1375
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1322
{"ignore-spaces", 'i', N_("Ignore space after function names."), 0, 0, 0,
1376
{"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0,
1323
1377
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1324
{"local-infile", OPT_LOCAL_INFILE, N_("Enable/disable LOAD DATA LOCAL INFILE."),
1325
(char**) &opt_local_infile,
1326
(char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1327
{"no-beep", 'b', N_("Turn off beep on error."), (char**) &opt_nobeep,
1328
(char**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1329
{"host", 'h', N_("Connect to host."), (char**) ¤t_host,
1330
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1331
{"line-numbers", OPT_LINE_NUMBERS, N_("Write line numbers for errors."),
1332
(char**) &line_numbers, (char**) &line_numbers, 0, GET_BOOL,
1333
NO_ARG, 1, 0, 0, 0, 0, 0},
1334
{"skip-line-numbers", 'L', N_("Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead."), 0, 0, 0, GET_NO_ARG,
1378
{"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.",
1379
(uchar**) &opt_local_infile,
1380
(uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1381
{"no-beep", 'b', "Turn off beep on error.", (uchar**) &opt_nobeep,
1382
(uchar**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1383
{"host", 'h', "Connect to host.", (uchar**) ¤t_host,
1384
(uchar**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1385
{"html", 'H', "Produce HTML output.", (uchar**) &opt_html, (uchar**) &opt_html,
1386
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1387
{"xml", 'X', "Produce XML output", (uchar**) &opt_xml, (uchar**) &opt_xml, 0,
1388
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1389
{"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.",
1390
(uchar**) &line_numbers, (uchar**) &line_numbers, 0, GET_BOOL,
1391
NO_ARG, 1, 0, 0, 0, 0, 0},
1392
{"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG,
1335
1393
NO_ARG, 0, 0, 0, 0, 0, 0},
1336
{"unbuffered", 'n', N_("Flush buffer after each query."), (char**) &unbuffered,
1337
(char**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1338
{"column-names", OPT_COLUMN_NAMES, N_("Write column names in results."),
1339
(char**) &column_names, (char**) &column_names, 0, GET_BOOL,
1394
{"unbuffered", 'n', "Flush buffer after each query.", (uchar**) &unbuffered,
1395
(uchar**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1396
{"column-names", OPT_COLUMN_NAMES, "Write column names in results.",
1397
(uchar**) &column_names, (uchar**) &column_names, 0, GET_BOOL,
1340
1398
NO_ARG, 1, 0, 0, 0, 0, 0},
1341
1399
{"skip-column-names", 'N',
1342
N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."),
1400
"Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead.",
1343
1401
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1344
1402
{"set-variable", 'O',
1345
N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."),
1403
"Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
1346
1404
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1347
{"sigint-ignore", OPT_SIGINT_IGNORE, N_("Ignore SIGINT (CTRL-C)"),
1348
(char**) &opt_sigint_ignore, (char**) &opt_sigint_ignore, 0, GET_BOOL,
1405
{"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C)",
1406
(uchar**) &opt_sigint_ignore, (uchar**) &opt_sigint_ignore, 0, GET_BOOL,
1349
1407
NO_ARG, 0, 0, 0, 0, 0, 0},
1350
1408
{"one-database", 'o',
1351
N_("Only update the default database. This is useful for skipping updates to other database in the update log."),
1409
"Only update the default database. This is useful for skipping updates to other database in the update log.",
1352
1410
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1353
1412
{"pager", OPT_PAGER,
1354
N_("Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default."),
1413
"Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default.",
1355
1414
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1356
1415
{"no-pager", OPT_NOPAGER,
1357
N_("Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead."),
1416
"Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead.",
1358
1417
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1359
1419
{"password", 'p',
1360
N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
1420
"Password to use when connecting to server. If password is not given it's asked from the tty.",
1361
1421
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1362
{"port", 'P', N_("Port number to use for connection or 0 for default to, in order of preference, my.cnf, $DRIZZLE_TCP_PORT, ")
1363
N_("built-in default") " (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
1364
(char**) &opt_drizzle_port,
1365
(char**) &opt_drizzle_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1366
{"prompt", OPT_PROMPT, N_("Set the drizzle prompt to this value."),
1367
(char**) ¤t_prompt, (char**) ¤t_prompt, 0, GET_STR_ALLOC,
1422
{"port", 'P', "Port number to use for connection or 0 for default to, in "
1423
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
1424
#if MYSQL_PORT_DEFAULT == 0
1427
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
1428
(uchar**) &opt_mysql_port,
1429
(uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1430
{"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",
1431
(uchar**) ¤t_prompt, (uchar**) ¤t_prompt, 0, GET_STR_ALLOC,
1368
1432
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1369
{"protocol", OPT_DRIZZLE_PROTOCOL, N_("The protocol of connection (tcp,socket,pipe,memory)."),
1433
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
1370
1434
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1372
N_("Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file."),
1373
(char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1374
{"raw", 'r', N_("Write fields without conversion. Used with --batch."),
1375
(char**) &opt_raw_data, (char**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1436
"Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.",
1437
(uchar**) &quick, (uchar**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1438
{"raw", 'r', "Write fields without conversion. Used with --batch.",
1439
(uchar**) &opt_raw_data, (uchar**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1377
{"reconnect", OPT_RECONNECT, N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."),
1378
(char**) &opt_reconnect, (char**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1379
{"silent", 's', N_("Be more silent. Print results with a tab as separator, each row on new line."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
1441
{"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.",
1442
(uchar**) &opt_reconnect, (uchar**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1443
{"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
1381
{"socket", 'S', N_("Socket file to use for connection."),
1382
(char**) &opt_drizzle_unix_port, (char**) &opt_drizzle_unix_port, 0, GET_STR_ALLOC,
1446
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
1447
"Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name,
1448
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1450
{"socket", 'S', "Socket file to use for connection.",
1451
(uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR_ALLOC,
1383
1452
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1384
{"table", 't', N_("Output in table format."), (char**) &output_tables,
1385
(char**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1453
{"table", 't', "Output in table format.", (uchar**) &output_tables,
1454
(uchar**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1386
1455
{"tee", OPT_TEE,
1387
N_("Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default."),
1456
"Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.",
1388
1457
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1389
{"no-tee", OPT_NOTEE, N_("Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead"), 0, 0, 0, GET_NO_ARG,
1458
{"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG,
1390
1459
NO_ARG, 0, 0, 0, 0, 0, 0},
1391
1460
#ifndef DONT_ALLOW_USER_CHANGE
1392
{"user", 'u', N_("User for login if not current user."), (char**) ¤t_user,
1393
(char**) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1461
{"user", 'u', "User for login if not current user.", (uchar**) ¤t_user,
1462
(uchar**) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1395
{"safe-updates", 'U', N_("Only allow UPDATE and DELETE that uses keys."),
1396
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1398
{"i-am-a-dummy", 'U', N_("Synonym for option --safe-updates, -U."),
1399
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1401
{"verbose", 'v', N_("Write more. (-v -v -v gives the table output format)."), 0,
1464
{"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.",
1465
(uchar**) &safe_updates, (uchar**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1467
{"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.",
1468
(uchar**) &safe_updates, (uchar**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1470
{"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0,
1402
1471
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1403
{"version", 'V', N_("Output version information and exit."), 0, 0, 0,
1472
{"version", 'V', "Output version information and exit.", 0, 0, 0,
1404
1473
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1405
{"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_NO_ARG,
1474
{"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG,
1406
1475
NO_ARG, 0, 0, 0, 0, 0, 0},
1407
1476
{"connect_timeout", OPT_CONNECT_TIMEOUT,
1408
N_("Number of seconds before connection timeout."),
1409
(char**) &opt_connect_timeout,
1410
(char**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
1477
"Number of seconds before connection timeout.",
1478
(uchar**) &opt_connect_timeout,
1479
(uchar**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
1412
1481
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
1413
N_("Max packet length to send to, or receive from server"),
1414
(char**) &opt_max_allowed_packet, (char**) &opt_max_allowed_packet, 0,
1482
"Max packet length to send to, or receive from server",
1483
(uchar**) &opt_max_allowed_packet, (uchar**) &opt_max_allowed_packet, 0,
1415
1484
GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
1416
(int64_t) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1485
(longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1417
1486
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
1418
N_("Buffer for TCP/IP and socket communication"),
1419
(char**) &opt_net_buffer_length, (char**) &opt_net_buffer_length, 0, GET_ULONG,
1487
"Buffer for TCP/IP and socket communication",
1488
(uchar**) &opt_net_buffer_length, (uchar**) &opt_net_buffer_length, 0, GET_ULONG,
1420
1489
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
1421
1490
{"select_limit", OPT_SELECT_LIMIT,
1422
N_("Automatic limit for SELECT when using --safe-updates"),
1423
(char**) &select_limit,
1424
(char**) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1491
"Automatic limit for SELECT when using --safe-updates",
1492
(uchar**) &select_limit,
1493
(uchar**) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1426
1495
{"max_join_size", OPT_MAX_JOIN_SIZE,
1427
N_("Automatic limit for rows in a join when using --safe-updates"),
1428
(char**) &max_join_size,
1429
(char**) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1496
"Automatic limit for rows in a join when using --safe-updates",
1497
(uchar**) &max_join_size,
1498
(uchar**) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1431
{"secure-auth", OPT_SECURE_AUTH, N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"), (char**) &opt_secure_auth,
1432
(char**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1433
{"show-warnings", OPT_SHOW_WARNINGS, N_("Show warnings after every statement."),
1434
(char**) &show_warnings, (char**) &show_warnings, 0, GET_BOOL, NO_ARG,
1500
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
1501
" uses old (pre-4.1.1) protocol", (uchar**) &opt_secure_auth,
1502
(uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1503
{"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.",
1504
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1505
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
1506
(uchar**) &show_warnings, (uchar**) &show_warnings, 0, GET_BOOL, NO_ARG,
1436
1508
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1440
1512
static void usage(int version)
1514
#if defined(USE_LIBEDIT_INTERFACE)
1515
const char* readline= "";
1442
1517
const char* readline= "readline";
1444
printf(_("%s Ver %s Distrib %s, for %s (%s) using %s %s\n"),
1445
my_progname, VER, drizzle_get_client_info(),
1446
SYSTEM_TYPE, MACHINE_TYPE,
1520
#ifdef HAVE_READLINE
1521
printf("%s Ver %s Distrib %s, for %s (%s) using %s %s\n",
1522
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE,
1447
1523
readline, rl_library_version);
1525
printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER,
1526
MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
1452
Copyright (C) 2000-2008 MySQL AB\n \
1453
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n \
1454
and you are welcome to modify and redistribute it under the GPL license\n"));
1455
printf(_("Usage: %s [OPTIONS] [database]\n"), my_progname);
1532
Copyright (C) 2000-2008 MySQL AB\n\
1533
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
1534
and you are welcome to modify and redistribute it under the GPL license\n");
1535
printf("Usage: %s [OPTIONS] [database]\n", my_progname);
1456
1536
my_print_help(my_long_options);
1457
1537
print_defaults("my", load_default_groups);
1458
1538
my_print_variables(my_long_options);
1463
1543
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
1466
1546
switch(optid) {
1467
1547
case OPT_CHARSETS_DIR:
1468
strmake(drizzle_charsets_dir, argument, sizeof(drizzle_charsets_dir) - 1);
1469
charsets_dir = drizzle_charsets_dir;
1548
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir) - 1);
1549
charsets_dir = mysql_charsets_dir;
1471
1551
case OPT_DEFAULT_CHARSET:
1472
1552
default_charset_used= 1;
1474
1554
case OPT_DELIMITER:
1475
if (argument == disabled_my_option)
1555
if (argument == disabled_my_option)
1477
my_stpcpy(delimiter, DEFAULT_DELIMITER);
1557
strmov(delimiter, DEFAULT_DELIMITER);
1481
1561
/* Check that delimiter does not contain a backslash */
1482
if (!strstr(argument, "\\"))
1562
if (!strstr(argument, "\\"))
1484
1564
strmake(delimiter, argument, sizeof(delimiter) - 1);
1488
put_info(_("DELIMITER cannot contain a backslash character"),
1568
put_info("DELIMITER cannot contain a backslash character", INFO_ERROR);
1493
1572
delimiter_length= (uint)strlen(delimiter);
1494
1573
delimiter_str= delimiter;