1310
1398
textdomain("drizzle");
1314
delimiter_str= delimiter;
1401
po::options_description commandline_options("Options used only in command line");
1402
commandline_options.add_options()
1403
("help,?",N_("Displays this help and exit."))
1404
("batch,B",N_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
1405
("column-type-info", po::value<bool>(&column_types_flag)->default_value(false)->zero_tokens(),
1406
N_("Display column type information."))
1407
("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(),
1408
N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
1409
("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
1410
N_("Use compression in server/client protocol."))
1411
("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(),
1412
N_("Print the output of a query (rows) vertically."))
1413
("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
1414
N_("Continue even if we get an sql error."))
1415
("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(),
1416
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."))
1417
("no-named-commands,g",
1418
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."))
1419
("ignore-spaces,i", N_("Ignore space after function names."))
1420
("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(),
1421
N_("Turn off beep on error."))
1422
("line-numbers", po::value<bool>(&line_numbers)->default_value(true)->zero_tokens(),
1423
N_("Write line numbers for errors."))
1424
("skip-line-numbers,L",
1425
N_("Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead."))
1426
("column-name", po::value<bool>(&column_names)->default_value(true)->zero_tokens(),
1427
N_("Write column names in results."))
1428
("skip-column-names,N",
1429
N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
1430
("set-variable,O", po::value<string>(),
1431
N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
1432
("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(),
1433
N_("Output in table format."))
1434
("safe-updates,U", po::value<bool>(&safe_updates)->default_value(0)->zero_tokens(),
1435
N_("Only allow UPDATE and DELETE that uses keys."))
1436
("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(0)->zero_tokens(),
1437
N_("Synonym for option --safe-updates, -U."))
1438
("verbose,v", po::value<string>(&opt_verbose)->default_value(""),
1439
N_("-v vvv implies that verbose= 3, Used to specify verbose"))
1440
("version,V", N_("Output version information and exit."))
1441
("secure-auth", po::value<bool>(&opt_secure_auth)->default_value(false)->zero_tokens(),
1442
N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"))
1443
("show-warnings", po::value<bool>(&show_warnings)->default_value(false)->zero_tokens(),
1444
N_("Show warnings after every statement."))
1445
("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(0),
1446
N_("Number of lines before each import progress report."))
1447
("ping", po::value<bool>(&opt_ping)->default_value(false)->zero_tokens(),
1448
N_("Ping the server to check if it's alive."))
1449
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1450
N_("Configuration file defaults are not used if no-defaults is set"))
1453
po::options_description drizzle_options("Options specific to the drizzle client");
1454
drizzle_options.add_options()
1455
("auto-rehash", po::value<bool>(&opt_rehash)->default_value(true)->zero_tokens(),
1456
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."))
1457
("no-auto-rehash,A",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."))
1458
("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(),
1459
N_("Automatically switch to vertical output mode if the result is wider than the terminal width."))
1460
("database,D", po::value<string>(¤t_db)->default_value(""),
1461
N_("Database to use."))
1462
("default-character-set",po::value<string>(),
1464
("delimiter", po::value<string>(&delimiter_str)->default_value(";"),
1465
N_("Delimiter to be used."))
1466
("execute,e", po::value<string>(),
1467
N_("Execute command and quit. (Disables --force and history file)"))
1468
("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(),
1469
N_("Enable/disable LOAD DATA LOCAL INFILE."))
1470
("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(),
1471
N_("Flush buffer after each query."))
1472
("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(),
1473
N_("Ignore SIGINT (CTRL-C)"))
1474
("one-database,o", po::value<bool>(&one_database)->default_value(false)->zero_tokens(),
1475
N_("Only update the default database. This is useful for skipping updates to other database in the update log."))
1476
("pager", po::value<string>(),
1477
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."))
1478
("disable-pager", po::value<bool>(&opt_nopager)->default_value(false)->zero_tokens(),
1479
N_("Disable pager and print to stdout. See interactive help (\\h) also."))
1480
("prompt", po::value<string>(¤t_prompt)->default_value(""),
1481
N_("Set the drizzle prompt to this value."))
1482
("quick,q", po::value<bool>(&quick)->default_value(false)->zero_tokens(),
1483
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."))
1484
("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(),
1485
N_("Write fields without conversion. Used with --batch."))
1486
("reconnect", po::value<bool>(&opt_reconnect)->default_value(true)->zero_tokens(),
1487
N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."))
1488
("shutdown", po::value<bool>(&opt_shutdown)->default_value(false)->zero_tokens(),
1489
N_("Shutdown the server"))
1490
("silent,s", N_("Be more silent. Print results with a tab as separator, each row on new line."))
1491
("tee", po::value<string>(),
1492
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."))
1493
("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(),
1494
N_("Disable outfile. See interactive help (\\h) also."))
1495
("wait,w", N_("Wait and retry if connection is down."))
1496
("connect_timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
1497
N_("Number of seconds before connection timeout."))
1498
("max_input_line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
1499
N_("Max length of input line"))
1500
("select_limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
1501
N_("Automatic limit for SELECT when using --safe-updates"))
1502
("max_join_size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
1503
N_("Automatic limit for rows in a join when using --safe-updates"))
1506
po::options_description client_options("Options specific to the client");
1507
client_options.add_options()
1508
("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(),
1509
N_("Use MySQL Protocol."))
1510
("host,h", po::value<string>(¤t_host)->default_value("localhost"),
1511
N_("Connect to host"))
1512
("password,P", po::value<string>(¤t_password)->default_value(PASSWORD_SENTINEL),
1513
N_("Password to use when connecting to server. If password is not given it's asked from the tty."))
1514
("port,p", po::value<uint32_t>()->default_value(0),
1515
N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1516
("user,u", po::value<string>(¤t_user)->default_value(""),
1517
N_("User for login if not current user."))
1518
("protocol",po::value<string>(),
1519
N_("The protocol of connection (tcp,socket,pipe,memory)."))
1522
po::options_description long_options("Allowed Options");
1523
long_options.add(commandline_options).add(drizzle_options).add(client_options);
1525
std::string system_config_dir_drizzle(SYSCONFDIR);
1526
system_config_dir_drizzle.append("/drizzle/drizzle.cnf");
1528
std::string system_config_dir_client(SYSCONFDIR);
1529
system_config_dir_client.append("/drizzle/client.cnf");
1531
po::variables_map vm;
1533
po::positional_options_description p;
1534
p.add("database", -1);
1536
po::store(po::command_line_parser(argc, argv).options(long_options).
1537
positional(p).extra_parser(parse_password_arg).run(), vm);
1539
if (! vm["no-defaults"].as<bool>())
1541
ifstream user_drizzle_ifs("~/.drizzle/drizzle.cnf");
1542
po::store(parse_config_file(user_drizzle_ifs, drizzle_options), vm);
1544
ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str());
1545
store(parse_config_file(system_drizzle_ifs, drizzle_options), vm);
1547
ifstream user_client_ifs("~/.drizzle/client.cnf");
1548
po::store(parse_config_file(user_client_ifs, client_options), vm);
1550
ifstream system_client_ifs(system_config_dir_client.c_str());
1551
po::store(parse_config_file(system_client_ifs, client_options), vm);
1315
1556
default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1316
1557
getenv("DRIZZLE_PS1") :
1319
1559
if (default_prompt == NULL)
1321
1561
fprintf(stderr, _("Memory allocation error while constructing initial "
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)
1987
static int process_options(void)
1939
1989
char *tmp, *pagpoint;
1942
1992
tmp= (char *) getenv("DRIZZLE_HOST");