1295
1300
return executed;
1298
static void check_timeout_value(uint32_t in_connect_timeout)
1300
opt_connect_timeout= 0;
1301
if (in_connect_timeout > 3600*12)
1303
cout << _("Error: Invalid Value for connect_timeout");
1306
opt_connect_timeout= in_connect_timeout;
1309
static void check_max_input_line(uint32_t in_max_input_line)
1311
opt_max_input_line= 0;
1312
if (in_max_input_line < 4096 || in_max_input_line > (int64_t)2*1024L*1024L*1024L)
1314
cout << _("Error: Invalid Value for max_input_line");
1317
opt_max_input_line= in_max_input_line - (in_max_input_line % 1024);
1320
1303
int main(int argc,char *argv[])
1325
1305
#if defined(ENABLE_NLS)
1326
1306
# if defined(HAVE_LOCALE_H)
1327
1307
setlocale(LC_ALL, "");
1329
bindtextdomain("drizzle7", LOCALEDIR);
1330
textdomain("drizzle7");
1333
po::options_description commandline_options(_("Options used only in command line"));
1334
commandline_options.add_options()
1335
("help,?",_("Displays this help and exit."))
1336
("batch,B",_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
1337
("column-type-info", po::value<bool>(&column_types_flag)->default_value(false)->zero_tokens(),
1338
_("Display column type information."))
1339
("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(),
1340
_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
1341
("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(),
1342
_("Print the output of a query (rows) vertically."))
1343
("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
1344
_("Continue even if we get an sql error."))
1345
("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(),
1346
_("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."))
1347
("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(),
1348
_("Turn off beep on error."))
1349
("disable-line-numbers", _("Do not write line numbers for errors."))
1350
("disable-column-names", _("Do not write column names in results."))
1351
("skip-column-names,N",
1352
_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
1353
("set-variable,O", po::value<string>(),
1354
_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
1355
("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(),
1356
_("Output in table format."))
1357
("safe-updates,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
1358
_("Only allow UPDATE and DELETE that uses keys."))
1359
("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
1360
_("Synonym for option --safe-updates, -U."))
1361
("verbose,v", po::value<string>(&opt_verbose)->default_value(""),
1362
_("-v vvv implies that verbose= 3, Used to specify verbose"))
1363
("version,V", _("Output version information and exit."))
1364
("secure-auth", po::value<bool>(&opt_secure_auth)->default_value(false)->zero_tokens(),
1365
_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"))
1366
("show-warnings", po::value<bool>(&show_warnings)->default_value(false)->zero_tokens(),
1367
_("Show warnings after every statement."))
1368
("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(0),
1369
_("Number of lines before each import progress report."))
1370
("ping", po::value<bool>(&opt_ping)->default_value(false)->zero_tokens(),
1371
_("Ping the server to check if it's alive."))
1372
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1373
_("Configuration file defaults are not used if no-defaults is set"))
1376
po::options_description drizzle_options(_("Options specific to the drizzle client"));
1377
drizzle_options.add_options()
1378
("disable-auto-rehash,A",
1379
_("Disable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time."))
1380
("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(),
1381
_("Automatically switch to vertical output mode if the result is wider than the terminal width."))
1382
("database,D", po::value<string>(¤t_db)->default_value(""),
1383
_("Database to use."))
1384
("default-character-set",po::value<string>(),
1386
("delimiter", po::value<string>(&delimiter_str)->default_value(";"),
1387
_("Delimiter to be used."))
1388
("execute,e", po::value<string>(),
1389
_("Execute command and quit. (Disables --force and history file)"))
1390
("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(),
1391
_("Enable LOAD DATA LOCAL INFILE."))
1392
("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(),
1393
_("Flush buffer after each query."))
1394
("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(),
1395
_("Ignore SIGINT (CTRL-C)"))
1396
("one-database,o", po::value<bool>(&one_database)->default_value(false)->zero_tokens(),
1397
_("Only update the default database. This is useful for skipping updates to other database in the update log."))
1398
("pager", po::value<string>(),
1399
_("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."))
1400
("disable-pager", po::value<bool>(&opt_nopager)->default_value(false)->zero_tokens(),
1401
_("Disable pager and print to stdout. See interactive help (\\h) also."))
1402
("prompt", po::value<string>(¤t_prompt)->default_value(""),
1403
_("Set the drizzle prompt to this value."))
1404
("quick,q", po::value<bool>(&quick)->default_value(false)->zero_tokens(),
1405
_("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."))
1406
("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(),
1407
_("Write fields without conversion. Used with --batch."))
1408
("disable-reconnect", _("Do not reconnect if the connection is lost."))
1409
("shutdown", po::value<bool>()->zero_tokens(),
1410
_("Shutdown the server"))
1411
("silent,s", _("Be more silent. Print results with a tab as separator, each row on new line."))
1412
("tee", po::value<string>(),
1413
_("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."))
1414
("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(),
1415
_("Disable outfile. See interactive help (\\h) also."))
1416
("connect-timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
1417
_("Number of seconds before connection timeout."))
1418
("max-input-line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
1419
_("Max length of input line"))
1420
("select-limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
1421
_("Automatic limit for SELECT when using --safe-updates"))
1422
("max-join-size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
1423
_("Automatic limit for rows in a join when using --safe-updates"))
1426
po::options_description client_options(_("Options specific to the client"));
1427
client_options.add_options()
1428
("host,h", po::value<string>(¤t_host)->default_value("localhost"),
1429
_("Connect to host"))
1430
("password,P", po::value<string>(¤t_password)->default_value(PASSWORD_SENTINEL),
1431
_("Password to use when connecting to server. If password is not given it's asked from the tty."))
1432
("port,p", po::value<uint32_t>()->default_value(0),
1433
_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1434
#ifdef DRIZZLE_ADMIN_TOOL
1435
("user,u", po::value<string>(¤t_user)->default_value("root"),
1437
("user,u", po::value<string>(¤t_user)->default_value(""),
1439
_("User for login if not current user."))
1440
("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
1441
_("The protocol of connection (mysql or drizzle)."))
1444
po::options_description long_options(_("Allowed Options"));
1445
long_options.add(commandline_options).add(drizzle_options).add(client_options);
1447
std::string system_config_dir_drizzle(SYSCONFDIR);
1448
system_config_dir_drizzle.append("/drizzle/drizzle.cnf");
1450
std::string system_config_dir_client(SYSCONFDIR);
1451
system_config_dir_client.append("/drizzle/client.cnf");
1453
std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
1455
if (user_config_dir.compare(0, 2, "~/") == 0)
1458
homedir= getenv("HOME");
1459
if (homedir != NULL)
1460
user_config_dir.replace(0, 1, homedir);
1463
po::variables_map vm;
1465
po::positional_options_description p;
1466
p.add("database", 1);
1468
// Disable allow_guessing
1469
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1471
po::store(po::command_line_parser(argc, argv).options(long_options).
1472
style(style).positional(p).extra_parser(parse_password_arg).run(),
1475
if (! vm["no-defaults"].as<bool>())
1477
std::string user_config_dir_drizzle(user_config_dir);
1478
user_config_dir_drizzle.append("/drizzle/drizzle.cnf");
1480
std::string user_config_dir_client(user_config_dir);
1481
user_config_dir_client.append("/drizzle/client.cnf");
1483
ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str());
1484
po::store(dpo::parse_config_file(user_drizzle_ifs, drizzle_options), vm);
1486
ifstream user_client_ifs(user_config_dir_client.c_str());
1487
po::store(dpo::parse_config_file(user_client_ifs, client_options), vm);
1489
ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str());
1490
store(dpo::parse_config_file(system_drizzle_ifs, drizzle_options), vm);
1492
ifstream system_client_ifs(system_config_dir_client.c_str());
1493
po::store(dpo::parse_config_file(system_client_ifs, client_options), vm);
1498
#ifdef DRIZZLE_ADMIN_TOOL
1499
default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1500
getenv("DRIZZLE_PS1") :
1309
bindtextdomain("drizzle", LOCALEDIR);
1310
textdomain("drizzle");
1314
delimiter_str= delimiter;
1503
1315
default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1504
1316
getenv("DRIZZLE_PS1") :
1507
1319
if (default_prompt == NULL)
1509
1321
fprintf(stderr, _("Memory allocation error while constructing initial "
1510
1322
"prompt. Aborting.\n"));
1514
if (current_prompt.empty())
1515
current_prompt= strdup(default_prompt);
1517
if (current_prompt.empty())
1325
current_prompt= strdup(default_prompt);
1326
if (current_prompt == NULL)
1519
1328
fprintf(stderr, _("Memory allocation error while constructing initial "
1520
1329
"prompt. Aborting.\n"));
1945
static int process_options(void)
1578
static struct option my_long_options[] =
1580
{"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1582
{"help", 'I', N_("Synonym for -?"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1584
{"auto-rehash", OPT_AUTO_REHASH,
1585
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."),
1586
(char**) &opt_rehash, (char**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1588
{"no-auto-rehash", 'A',
1589
N_("No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of drizzle_st and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead."),
1590
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1591
{"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
1592
N_("Automatically switch to vertical output mode if the result is wider than the terminal width."),
1593
(char**) &auto_vertical_output, (char**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1595
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},
1596
{"column-type-info", OPT_COLUMN_TYPES, N_("Display column type information."),
1597
(char**) &column_types_flag, (char**) &column_types_flag,
1598
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1599
{"comments", 'c', N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"),
1600
(char**) &preserve_comments, (char**) &preserve_comments,
1601
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1602
{"compress", 'C', N_("Use compression in server/client protocol."),
1603
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1605
{"database", 'D', N_("Database to use."), (char**) ¤t_db,
1606
(char**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1607
{"default-character-set", OPT_DEFAULT_CHARSET,
1608
N_("(not used)"), 0,
1609
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1610
{"delimiter", OPT_DELIMITER, N_("Delimiter to be used."), (char**) &delimiter_str,
1611
(char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1612
{"execute", 'e', N_("Execute command and quit. (Disables --force and history file)"), 0,
1613
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1614
{"vertical", 'E', N_("Print the output of a query (rows) vertically."),
1615
(char**) &vertical, (char**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1617
{"force", 'f', N_("Continue even if we get an sql error."),
1618
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1620
{"named-commands", 'G',
1621
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."),
1622
(char**) &named_cmds, (char**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1624
{"no-named-commands", 'g',
1625
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."),
1626
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1627
{"ignore-spaces", 'i', N_("Ignore space after function names."), 0, 0, 0,
1628
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1629
{"local-infile", OPT_LOCAL_INFILE, N_("Enable/disable LOAD DATA LOCAL INFILE."),
1630
(char**) &opt_local_infile,
1631
(char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1632
{"no-beep", 'b', N_("Turn off beep on error."), (char**) &opt_nobeep,
1633
(char**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1634
{"host", 'h', N_("Connect to host."), (char**) ¤t_host,
1635
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1636
{"line-numbers", OPT_LINE_NUMBERS, N_("Write line numbers for errors."),
1637
(char**) &line_numbers, (char**) &line_numbers, 0, GET_BOOL,
1638
NO_ARG, 1, 0, 0, 0, 0, 0},
1639
{"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,
1640
NO_ARG, 0, 0, 0, 0, 0, 0},
1641
{"unbuffered", 'n', N_("Flush buffer after each query."), (char**) &unbuffered,
1642
(char**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1643
{"column-names", OPT_COLUMN_NAMES, N_("Write column names in results."),
1644
(char**) &column_names, (char**) &column_names, 0, GET_BOOL,
1645
NO_ARG, 1, 0, 0, 0, 0, 0},
1646
{"skip-column-names", 'N',
1647
N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."),
1648
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1649
{"set-variable", 'O',
1650
N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."),
1651
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1652
{"sigint-ignore", OPT_SIGINT_IGNORE, N_("Ignore SIGINT (CTRL-C)"),
1653
(char**) &opt_sigint_ignore, (char**) &opt_sigint_ignore, 0, GET_BOOL,
1654
NO_ARG, 0, 0, 0, 0, 0, 0},
1655
{"one-database", 'o',
1656
N_("Only update the default database. This is useful for skipping updates to other database in the update log."),
1657
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1658
{"pager", OPT_PAGER,
1659
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."),
1660
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1661
{"no-pager", OPT_NOPAGER,
1662
N_("Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead."),
1663
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1665
N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
1666
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1667
{"port", 'p', N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, ")
1668
N_("built-in default") " (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
1669
0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1670
{"prompt", OPT_PROMPT, N_("Set the drizzle prompt to this value."),
1671
(char**) ¤t_prompt, (char**) ¤t_prompt, 0, GET_STR_ALLOC,
1672
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1674
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."),
1675
(char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1676
{"raw", 'r', N_("Write fields without conversion. Used with --batch."),
1677
(char**) &opt_raw_data, (char**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1679
{"reconnect", OPT_RECONNECT, N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."),
1680
(char**) &opt_reconnect, (char**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1681
{"shutdown", OPT_SHUTDOWN, N_("Shutdown the server."),
1682
(char**) &opt_shutdown, (char**) &opt_shutdown, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1683
{"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,
1685
{"table", 't', N_("Output in table format."), (char**) &output_tables,
1686
(char**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1688
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."),
1689
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1690
{"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,
1691
NO_ARG, 0, 0, 0, 0, 0, 0},
1692
{"user", 'u', N_("User for login if not current user."), (char**) ¤t_user,
1693
(char**) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1694
{"safe-updates", 'U', N_("Only allow UPDATE and DELETE that uses keys."),
1695
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1697
{"i-am-a-dummy", 'U', N_("Synonym for option --safe-updates, -U."),
1698
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1700
{"verbose", 'v', N_("Write more. (-v -v -v gives the table output format)."), 0,
1701
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1702
{"version", 'V', N_("Output version information and exit."), 0, 0, 0,
1703
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1704
{"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_NO_ARG,
1705
NO_ARG, 0, 0, 0, 0, 0, 0},
1706
{"connect_timeout", OPT_CONNECT_TIMEOUT,
1707
N_("Number of seconds before connection timeout."),
1708
(char**) &opt_connect_timeout,
1709
(char**) &opt_connect_timeout, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 3600*12, 0,
1711
{"max_input_line", OPT_MAX_INPUT_LINE,
1712
N_("Max length of input line"),
1713
(char**) &opt_max_input_line, (char**) &opt_max_input_line, 0,
1714
GET_UINT32, REQUIRED_ARG, 16 *1024L*1024L, 4096,
1715
(int64_t) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1716
{"select_limit", OPT_SELECT_LIMIT,
1717
N_("Automatic limit for SELECT when using --safe-updates"),
1718
(char**) &select_limit,
1719
(char**) &select_limit, 0, GET_UINT32, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1721
{"max_join_size", OPT_MAX_JOIN_SIZE,
1722
N_("Automatic limit for rows in a join when using --safe-updates"),
1723
(char**) &max_join_size,
1724
(char**) &max_join_size, 0, GET_UINT32, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1726
{"secure-auth", OPT_SECURE_AUTH, N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"), (char**) &opt_secure_auth,
1727
(char**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1728
{"show-warnings", OPT_SHOW_WARNINGS, N_("Show warnings after every statement."),
1729
(char**) &show_warnings, (char**) &show_warnings, 0, GET_BOOL, NO_ARG,
1731
{"show-progress-size", OPT_SHOW_PROGRESS_SIZE, N_("Number of lines before each import progress report."),
1732
(char**) &show_progress_size, (char**) &show_progress_size, 0, GET_UINT32, REQUIRED_ARG,
1734
{"ping", OPT_PING, N_("Ping the server to check if it's alive."),
1735
(char**) &opt_ping, (char**) &opt_ping, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1736
{"mysql", 'm', N_("Use MySQL Protocol."),
1737
(char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
1739
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1743
static void usage(int version)
1745
const char* readline= "readline";
1747
printf(_("%s Ver %s Distrib %s, for %s-%s (%s) using %s %s\n"),
1748
internal::my_progname, VER.c_str(), drizzle_version(),
1749
HOST_VENDOR, HOST_OS, HOST_CPU,
1750
readline, rl_library_version);
1754
printf(_("Copyright (C) 2008 Sun Microsystems\n"
1755
"This software comes with ABSOLUTELY NO WARRANTY. "
1756
"This is free software,\n"
1757
"and you are welcome to modify and redistribute it "
1758
"under the GPL license\n"));
1759
printf(_("Usage: %s [OPTIONS] [database]\n"), internal::my_progname);
1760
my_print_help(my_long_options);
1761
internal::print_defaults("drizzle", load_default_groups);
1762
my_print_variables(my_long_options);
1766
static int get_one_option(int optid, const struct option *, char *argument)
1768
char *endchar= NULL;
1769
uint64_t temp_drizzle_port= 0;
1772
case OPT_DEFAULT_CHARSET:
1773
default_charset_used= 1;
1776
if (argument == disabled_my_option)
1778
strcpy(delimiter, DEFAULT_DELIMITER);
1782
/* Check that delimiter does not contain a backslash */
1783
if (!strstr(argument, "\\"))
1785
strncpy(delimiter, argument, sizeof(delimiter) - 1);
1789
put_info(_("DELIMITER cannot contain a backslash character"),
1794
delimiter_length= (uint32_t)strlen(delimiter);
1795
delimiter_str= delimiter;
1798
if (argument == disabled_my_option)
1807
printf(_("WARNING: option deprecated; use --disable-tee instead.\n"));
1812
if (argument == disabled_my_option)
1817
if (argument && strlen(argument))
1819
default_pager_set= 1;
1820
strncpy(pager, argument, sizeof(pager) - 1);
1821
strcpy(default_pager, pager);
1823
else if (default_pager_set)
1824
strcpy(pager, default_pager);
1830
printf(_("WARNING: option deprecated; use --disable-pager instead.\n"));
1833
case OPT_SERVER_ARG:
1834
printf(_("WARNING: --server-arg option not supported in this configuration.\n"));
1844
status.setAddToHistory(1);
1845
if (status.getLineBuff() == NULL)
1846
status.setLineBuff(opt_max_input_line,NULL);
1847
if (status.getLineBuff() == NULL)
1852
status.getLineBuff()->addString(argument);
1855
if (argument == disabled_my_option)
1858
one_database= skip_updates= 1;
1861
temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
1862
/* if there is an alpha character this is not a valid port */
1863
if (strlen(endchar) != 0)
1865
put_info(_("Non-integer value supplied for port. If you are trying to enter a password please use --password instead."), INFO_ERROR, 0, 0);
1868
/* If the port number is > 65535 it is not a valid port
1869
This also helps with potential data loss casting unsigned long to a
1871
if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
1873
put_info(_("Value supplied for port is not valid."), INFO_ERROR, 0, 0);
1878
opt_drizzle_port= (uint32_t) temp_drizzle_port;
1882
/* Don't require password */
1883
if (argument == disabled_my_option)
1885
argument= (char*) "";
1889
char *start= argument;
1891
opt_password= strdup(argument);
1894
/* Overwriting password with 'x' */
1909
if (argument == disabled_my_option)
1915
if (argument == disabled_my_option)
1922
status.setAddToHistory(0);
1923
set_if_bigger(opt_silent,1); // more silent
1937
static int get_options(int argc, char **argv)
1947
1939
char *tmp, *pagpoint;
1950
1942
tmp= (char *) getenv("DRIZZLE_HOST");
1952
current_host.assign(tmp);
1944
current_host= strdup(tmp);
1954
1946
pagpoint= getenv("PAGER");
1955
1947
if (!((char*) (pagpoint)))
1957
pager.assign("stdout");
1949
strcpy(pager, "stdout");
1958
1950
opt_nopager= 1;
1962
pager.assign(pagpoint);
1964
default_pager.assign(pager);
1953
strcpy(pager, pagpoint);
1954
strcpy(default_pager, pager);
1956
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
1968
1959
if (status.getBatch()) /* disable pager and outfile in this case */
1970
default_pager.assign("stdout");
1971
pager.assign("stdout");
1961
strcpy(default_pager, "stdout");
1962
strcpy(pager, "stdout");
1972
1963
opt_nopager= 1;
1973
1964
default_pager_set= 0;
1974
1965
opt_outfile= 0;