1421
static struct option my_long_options[] =
1269
static struct my_option my_long_options[] =
1423
1271
{"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1425
1273
{"help", 'I', N_("Synonym for -?"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1427
1275
{"auto-rehash", OPT_AUTO_REHASH,
1428
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."),
1429
(char**) &opt_rehash, (char**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1276
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."),
1277
(char**) &opt_rehash, (char**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1431
1279
{"no-auto-rehash", 'A',
1432
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."),
1433
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1280
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."),
1281
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1434
1282
{"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
1435
N_("Automatically switch to vertical output mode if the result is wider than the terminal width."),
1436
(char**) &auto_vertical_output, (char**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1283
N_("Automatically switch to vertical output mode if the result is wider than the terminal width."),
1284
(char**) &auto_vertical_output, (char**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1438
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},
1286
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},
1287
{"character-sets-dir", OPT_CHARSETS_DIR,
1288
N_("Directory where character sets are."), (char**) &charsets_dir,
1289
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1439
1290
{"column-type-info", OPT_COLUMN_TYPES, N_("Display column type information."),
1440
(char**) &column_types_flag, (char**) &column_types_flag,
1441
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1291
(char**) &column_types_flag, (char**) &column_types_flag,
1292
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1442
1293
{"comments", 'c', N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"),
1443
(char**) &preserve_comments, (char**) &preserve_comments,
1444
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1294
(char**) &preserve_comments, (char**) &preserve_comments,
1295
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1445
1296
{"compress", 'C', N_("Use compression in server/client protocol."),
1446
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1297
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1299
{"debug-check", OPT_DEBUG_CHECK, N_("Check memory and open file usage at exit ."),
1300
(char**) &debug_check_flag, (char**) &debug_check_flag, 0,
1301
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1302
{"debug-info", 'T', N_("Print some debug info at exit."), (char**) &debug_info_flag,
1303
(char**) &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1448
1304
{"database", 'D', N_("Database to use."), (char**) ¤t_db,
1449
(char**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1305
(char**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1450
1306
{"default-character-set", OPT_DEFAULT_CHARSET,
1451
N_("(not used)"), 0,
1452
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1307
N_("Set the default character set."), (char**) &default_charset,
1308
(char**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1453
1309
{"delimiter", OPT_DELIMITER, N_("Delimiter to be used."), (char**) &delimiter_str,
1454
(char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1310
(char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1455
1311
{"execute", 'e', N_("Execute command and quit. (Disables --force and history file)"), 0,
1456
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1312
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1457
1313
{"vertical", 'E', N_("Print the output of a query (rows) vertically."),
1458
(char**) &vertical, (char**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1314
(char**) &vertical, (char**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1460
1316
{"force", 'f', N_("Continue even if we get an sql error."),
1461
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1317
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1463
1319
{"named-commands", 'G',
1464
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."),
1465
(char**) &named_cmds, (char**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1320
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."),
1321
(char**) &named_cmds, (char**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1467
1323
{"no-named-commands", 'g',
1468
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."),
1469
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1324
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."),
1325
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1470
1326
{"ignore-spaces", 'i', N_("Ignore space after function names."), 0, 0, 0,
1471
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1327
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1472
1328
{"local-infile", OPT_LOCAL_INFILE, N_("Enable/disable LOAD DATA LOCAL INFILE."),
1473
(char**) &opt_local_infile,
1474
(char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1329
(char**) &opt_local_infile,
1330
(char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1475
1331
{"no-beep", 'b', N_("Turn off beep on error."), (char**) &opt_nobeep,
1476
(char**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1332
(char**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1477
1333
{"host", 'h', N_("Connect to host."), (char**) ¤t_host,
1478
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1334
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1479
1335
{"line-numbers", OPT_LINE_NUMBERS, N_("Write line numbers for errors."),
1480
(char**) &line_numbers, (char**) &line_numbers, 0, GET_BOOL,
1481
NO_ARG, 1, 0, 0, 0, 0, 0},
1336
(char**) &line_numbers, (char**) &line_numbers, 0, GET_BOOL,
1337
NO_ARG, 1, 0, 0, 0, 0, 0},
1482
1338
{"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,
1483
NO_ARG, 0, 0, 0, 0, 0, 0},
1339
NO_ARG, 0, 0, 0, 0, 0, 0},
1484
1340
{"unbuffered", 'n', N_("Flush buffer after each query."), (char**) &unbuffered,
1485
(char**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1341
(char**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1486
1342
{"column-names", OPT_COLUMN_NAMES, N_("Write column names in results."),
1487
(char**) &column_names, (char**) &column_names, 0, GET_BOOL,
1488
NO_ARG, 1, 0, 0, 0, 0, 0},
1343
(char**) &column_names, (char**) &column_names, 0, GET_BOOL,
1344
NO_ARG, 1, 0, 0, 0, 0, 0},
1489
1345
{"skip-column-names", 'N',
1490
N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."),
1491
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1346
N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."),
1347
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1492
1348
{"set-variable", 'O',
1493
N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."),
1494
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1349
N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."),
1350
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1495
1351
{"sigint-ignore", OPT_SIGINT_IGNORE, N_("Ignore SIGINT (CTRL-C)"),
1496
(char**) &opt_sigint_ignore, (char**) &opt_sigint_ignore, 0, GET_BOOL,
1497
NO_ARG, 0, 0, 0, 0, 0, 0},
1352
(char**) &opt_sigint_ignore, (char**) &opt_sigint_ignore, 0, GET_BOOL,
1353
NO_ARG, 0, 0, 0, 0, 0, 0},
1498
1354
{"one-database", 'o',
1499
N_("Only update the default database. This is useful for skipping updates to other database in the update log."),
1500
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1355
N_("Only update the default database. This is useful for skipping updates to other database in the update log."),
1356
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1501
1357
{"pager", OPT_PAGER,
1502
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."),
1503
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1358
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."),
1359
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1504
1360
{"no-pager", OPT_NOPAGER,
1505
N_("Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead."),
1506
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1508
N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
1509
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1510
{"port", 'p', N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, ")
1511
N_("built-in default") " (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
1512
0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1361
N_("Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead."),
1362
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1364
N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
1365
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1366
{"port", 'P', N_("Port number to use for connection or 0 for default to, in order of preference, my.cnf, $DRIZZLE_TCP_PORT, ")
1367
N_("built-in default") " (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
1368
(char**) &opt_drizzle_port,
1369
(char**) &opt_drizzle_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1513
1370
{"prompt", OPT_PROMPT, N_("Set the drizzle prompt to this value."),
1514
(char**) ¤t_prompt, (char**) ¤t_prompt, 0, GET_STR_ALLOC,
1515
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1371
(char**) ¤t_prompt, (char**) ¤t_prompt, 0, GET_STR_ALLOC,
1372
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1373
{"protocol", OPT_DRIZZLE_PROTOCOL, N_("The protocol of connection (tcp,socket,pipe,memory)."),
1374
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1517
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."),
1518
(char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1376
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."),
1377
(char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1519
1378
{"raw", 'r', N_("Write fields without conversion. Used with --batch."),
1520
(char**) &opt_raw_data, (char**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1379
(char**) &opt_raw_data, (char**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1522
1381
{"reconnect", OPT_RECONNECT, N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."),
1523
(char**) &opt_reconnect, (char**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1524
{"shutdown", OPT_SHUTDOWN, N_("Shutdown the server."),
1525
(char**) &opt_shutdown, (char**) &opt_shutdown, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1382
(char**) &opt_reconnect, (char**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1526
1383
{"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,
1385
{"socket", 'S', N_("Socket file to use for connection."),
1386
(char**) &opt_drizzle_unix_port, (char**) &opt_drizzle_unix_port, 0, GET_STR_ALLOC,
1387
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1528
1388
{"table", 't', N_("Output in table format."), (char**) &output_tables,
1529
(char**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1389
(char**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1530
1390
{"tee", OPT_TEE,
1531
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."),
1532
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1391
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."),
1392
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1533
1393
{"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,
1534
NO_ARG, 0, 0, 0, 0, 0, 0},
1394
NO_ARG, 0, 0, 0, 0, 0, 0},
1395
#ifndef DONT_ALLOW_USER_CHANGE
1535
1396
{"user", 'u', N_("User for login if not current user."), (char**) ¤t_user,
1536
(char**) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1397
(char**) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1537
1399
{"safe-updates", 'U', N_("Only allow UPDATE and DELETE that uses keys."),
1538
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1400
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1540
1402
{"i-am-a-dummy", 'U', N_("Synonym for option --safe-updates, -U."),
1541
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1403
(char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1543
1405
{"verbose", 'v', N_("Write more. (-v -v -v gives the table output format)."), 0,
1544
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1406
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1545
1407
{"version", 'V', N_("Output version information and exit."), 0, 0, 0,
1546
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1408
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1547
1409
{"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_NO_ARG,
1548
NO_ARG, 0, 0, 0, 0, 0, 0},
1410
NO_ARG, 0, 0, 0, 0, 0, 0},
1549
1411
{"connect_timeout", OPT_CONNECT_TIMEOUT,
1550
N_("Number of seconds before connection timeout."),
1551
(char**) &opt_connect_timeout,
1552
(char**) &opt_connect_timeout, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 3600*12, 0,
1554
{"max_input_line", OPT_MAX_INPUT_LINE,
1555
N_("Max length of input line"),
1556
(char**) &opt_max_input_line, (char**) &opt_max_input_line, 0,
1557
GET_UINT32, REQUIRED_ARG, 16 *1024L*1024L, 4096,
1558
(int64_t) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1412
N_("Number of seconds before connection timeout."),
1413
(char**) &opt_connect_timeout,
1414
(char**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
1416
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
1417
N_("Max packet length to send to, or receive from server"),
1418
(char**) &opt_max_allowed_packet, (char**) &opt_max_allowed_packet, 0,
1419
GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
1420
(int64_t) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1421
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
1422
N_("Buffer for TCP/IP and socket communication"),
1423
(char**) &opt_net_buffer_length, (char**) &opt_net_buffer_length, 0, GET_ULONG,
1424
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
1559
1425
{"select_limit", OPT_SELECT_LIMIT,
1560
N_("Automatic limit for SELECT when using --safe-updates"),
1561
(char**) &select_limit,
1562
(char**) &select_limit, 0, GET_UINT32, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1426
N_("Automatic limit for SELECT when using --safe-updates"),
1427
(char**) &select_limit,
1428
(char**) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1564
1430
{"max_join_size", OPT_MAX_JOIN_SIZE,
1565
N_("Automatic limit for rows in a join when using --safe-updates"),
1566
(char**) &max_join_size,
1567
(char**) &max_join_size, 0, GET_UINT32, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1431
N_("Automatic limit for rows in a join when using --safe-updates"),
1432
(char**) &max_join_size,
1433
(char**) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1569
1435
{"secure-auth", OPT_SECURE_AUTH, N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"), (char**) &opt_secure_auth,
1570
(char**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1436
(char**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1571
1437
{"show-warnings", OPT_SHOW_WARNINGS, N_("Show warnings after every statement."),
1572
(char**) &show_warnings, (char**) &show_warnings, 0, GET_BOOL, NO_ARG,
1574
{"show-progress-size", OPT_SHOW_PROGRESS_SIZE, N_("Number of lines before each import progress report."),
1575
(char**) &show_progress_size, (char**) &show_progress_size, 0, GET_UINT32, REQUIRED_ARG,
1577
{"ping", OPT_PING, N_("Ping the server to check if it's alive."),
1578
(char**) &opt_ping, (char**) &opt_ping, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1579
{"mysql", 'm', N_("Use MySQL Protocol."),
1580
(char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
1438
(char**) &show_warnings, (char**) &show_warnings, 0, GET_BOOL, NO_ARG,
1582
1440
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2355
2198
return (char**) 0;
2358
inline string lower_string(const string &from_string)
2360
string to_string= from_string;
2361
transform(to_string.begin(), to_string.end(),
2362
to_string.begin(), ::tolower);
2365
inline string lower_string(const char * from_string)
2367
string to_string= from_string;
2368
return lower_string(to_string);
2372
class CompletionMatch :
2373
public unary_function<const string&, bool>
2378
CompletionMatch(string text) : match_text(text) {}
2379
inline bool operator() (const pair<string,string> &match_against) const
2382
lower_string(match_against.first.substr(0,match_text.size()));
2383
return match_func(sub_match,match_text);
2390
char *new_command_generator(const char *text, int state)
2202
static char *new_command_generator(const char *text,int state)
2395
completion_string= lower_string(text);
2396
if (completion_string.size() == 0)
2398
completion_iter= completion_map.begin();
2399
completion_end= completion_map.end();
2403
completion_iter= find_if(completion_map.begin(), completion_map.end(),
2404
CompletionMatch<equal_to<string> >(completion_string));
2405
completion_end= find_if(completion_iter, completion_map.end(),
2406
CompletionMatch<not_equal_to<string> >(completion_string));
2409
if (completion_iter == completion_end || (size_t)state > completion_map.size())
2411
char *result= (char *)malloc((*completion_iter).second.size()+1);
2412
strcpy(result, (*completion_iter).second.c_str());
2211
textlen=(uint) strlen(text);
2214
{ /* lookup in the hash */
2219
b = find_all_matches(&ht,text,(uint) strlen(text),&len);
2227
ptr= strdup(e->str);
2233
{ /* traverse the entire hash, ugly but works */
2237
/* find the first used bucket */
2238
for (i=0 ; i < ht.nTableSize ; i++)
2240
if (ht.arBuckets[i])
2242
b = ht.arBuckets[i];
2250
{ /* find valid entry in bucket */
2251
if ((uint) strlen(e->str) == b->nKeyLength)
2252
ptr = strdup(e->str);
2253
/* find the next used entry */
2256
{ /* find the next used bucket */
2260
for (i++ ; i<ht.nTableSize; i++)
2262
if (ht.arBuckets[i])
2264
b = ht.arBuckets[i];
2417
2281
/* Build up the completion hash */
2419
2283
static void build_completion_hash(bool rehash, bool write_info)
2421
2285
COMMANDS *cmd=commands;
2422
drizzle_return_t ret;
2423
drizzle_result_st databases,tables,fields;
2424
drizzle_row_t database_row,table_row;
2425
drizzle_column_st *sql_field;
2426
string tmp_str, tmp_str_lower;
2286
DRIZZLE_RES *databases=0,*tables=0;
2287
DRIZZLE_RES *fields;
2288
static char ***field_names= 0;
2289
DRIZZLE_ROW database_row,table_row;
2290
DRIZZLE_FIELD *sql_field;
2291
char buf[NAME_LEN*2+2]; // table name plus field name plus 2
2428
2295
if (status.batch || quick || !current_db)
2429
2296
return; // We don't need completion in batches
2433
completion_map.clear();
2300
/* Free old used memory */
2303
completion_hash_clean(&ht);
2304
free_root(&hash_mem_root,MYF(0));
2435
2306
/* hash this file's known subset of SQL commands */
2436
2307
while (cmd->name) {
2438
tmp_str_lower= lower_string(tmp_str);
2439
completion_map[tmp_str_lower]= tmp_str;
2308
add_word(&ht,(char*) cmd->name);
2443
2312
/* hash Drizzle functions (to be implemented) */
2445
2314
/* hash all database names */
2446
if (drizzle_query_str(&con, &databases, "show databases", &ret) != NULL)
2315
if (drizzle_query(&drizzle,"show databases") == 0)
2448
if (ret == DRIZZLE_RETURN_OK)
2317
if (!(databases = drizzle_store_result(&drizzle)))
2318
put_info(drizzle_error(&drizzle),INFO_INFO,0,0);
2450
if (drizzle_result_buffer(&databases) != DRIZZLE_RETURN_OK)
2451
put_info(drizzle_error(&drizzle),INFO_INFO,0,0);
2321
while ((database_row=drizzle_fetch_row(databases)))
2454
while ((database_row=drizzle_row_next(&databases)))
2456
tmp_str= database_row[0];
2457
tmp_str_lower= lower_string(tmp_str);
2458
completion_map[tmp_str_lower]= tmp_str;
2323
char *str=strdup_root(&hash_mem_root, (char*) database_row[0]);
2325
add_word(&ht,(char*) str);
2327
drizzle_free_result(databases);
2463
drizzle_result_free(&databases);
2466
2330
/* hash all table names */
2467
if (drizzle_query_str(&con, &tables, "show tables", &ret) != NULL)
2331
if (drizzle_query(&drizzle,"show tables")==0)
2469
if (ret != DRIZZLE_RETURN_OK)
2471
drizzle_result_free(&tables);
2475
if (drizzle_result_buffer(&tables) != DRIZZLE_RETURN_OK)
2333
if (!(tables = drizzle_store_result(&drizzle)))
2476
2334
put_info(drizzle_error(&drizzle),INFO_INFO,0,0);
2479
if (drizzle_result_row_count(&tables) > 0 && !opt_silent && write_info)
2337
if (drizzle_num_rows(tables) > 0 && !opt_silent && write_info)
2481
2339
tee_fprintf(stdout, _("\
2482
Reading table information for completion of table and column names\n \
2483
You can turn off this feature to get a quicker startup with -A\n\n"));
2340
Reading table information for completion of table and column names\n \
2341
You can turn off this feature to get a quicker startup with -A\n\n"));
2485
while ((table_row=drizzle_row_next(&tables)))
2343
while ((table_row=drizzle_fetch_row(tables)))
2487
tmp_str= table_row[0];
2488
tmp_str_lower= lower_string(tmp_str);
2489
completion_map[tmp_str_lower]= tmp_str;
2345
char *str=strdup_root(&hash_mem_root, (char*) table_row[0]);
2347
!completion_hash_exists(&ht,(char*) str, (uint) strlen(str)))
2496
2353
/* hash all field names, both with the table prefix and without it */
2497
if (drizzle_result_row_count(&tables) == 0)
2499
drizzle_result_free(&tables);
2503
drizzle_row_seek(&tables, 0);
2505
while ((table_row=drizzle_row_next(&tables)))
2509
query.append("show fields in '");
2510
query.append(table_row[0]);
2513
if (drizzle_query(&con, &fields, query.c_str(), query.length(),
2354
if (!tables) /* no tables */
2358
drizzle_data_seek(tables,0);
2359
if (!(field_names= (char ***) alloc_root(&hash_mem_root,sizeof(char **) *
2360
(uint) (drizzle_num_rows(tables)+1))))
2362
drizzle_free_result(tables);
2366
while ((table_row=drizzle_fetch_row(tables)))
2368
if ((fields=drizzle_list_fields(&drizzle,(const char*) table_row[0],NullS)))
2516
if (ret == DRIZZLE_RETURN_OK &&
2517
drizzle_result_buffer(&fields) == DRIZZLE_RETURN_OK)
2519
while ((sql_field=drizzle_column_next(&fields)))
2521
tmp_str=table_row[0];
2522
tmp_str.append(".");
2523
tmp_str.append(drizzle_column_name(sql_field));
2524
tmp_str_lower= lower_string(tmp_str);
2525
completion_map[tmp_str_lower]= tmp_str;
2527
tmp_str=drizzle_column_name(sql_field);
2528
tmp_str_lower= lower_string(tmp_str);
2529
completion_map[tmp_str_lower]= tmp_str;
2532
drizzle_result_free(&fields);
2370
num_fields=drizzle_num_fields(fields);
2371
if (!(field_names[i] = (char **) alloc_root(&hash_mem_root,
2375
drizzle_free_result(fields);
2378
field_names[i][num_fields*2]= '\0';
2380
while ((sql_field=drizzle_fetch_field(fields)))
2382
sprintf(buf,"%.64s.%.64s",table_row[0],sql_field->name);
2383
field_names[i][j] = strdup_root(&hash_mem_root,buf);
2384
add_word(&ht,field_names[i][j]);
2385
field_names[i][num_fields+j] = strdup_root(&hash_mem_root,
2387
if (!completion_hash_exists(&ht,field_names[i][num_fields+j],
2388
(uint) strlen(field_names[i][num_fields+j])))
2389
add_word(&ht,field_names[i][num_fields+j]);
2392
drizzle_free_result(fields);
2535
drizzle_result_free(&tables);
2536
completion_iter= completion_map.begin();
2399
drizzle_free_result(tables);
2400
field_names[i]=0; // End pointer
2539
2404
/* for gnu readline */
2408
extern char *index(const char *,int c),*rindex(const char *,int);
2410
char *index(const char *s,int c)
2414
if (*s == (char) c) return (char*) s;
2415
if (!*s++) return NullS;
2419
char *rindex(const char *s,int c)
2424
do if (*s == (char) c) t = (char*) s; while (*s++);
2542
2431
static int reconnect(void)
2433
/* purecov: begin tested */
2544
2434
if (opt_reconnect)
2546
2436
put_info(_("No connection. Trying to reconnect..."),INFO_INFO,0,0);
2547
2437
(void) com_connect((string *)0, 0);
2548
if (opt_rehash && connected)
2549
2439
com_rehash(NULL, NULL);
2552
2442
return put_info(_("Can't connect to the server\n"),INFO_ERROR,0,0);
2556
2447
static void get_current_db(void)
2558
drizzle_return_t ret;
2559
drizzle_result_st res;
2451
my_free(current_db, MYF(MY_ALLOW_ZERO_PTR));
2562
2452
current_db= NULL;
2563
2453
/* In case of error below current_db will be NULL */
2564
if (drizzle_query_str(&con, &res, "SELECT DATABASE()", &ret) != NULL)
2454
if (!drizzle_query(&drizzle, "SELECT DATABASE()") &&
2455
(res= drizzle_use_result(&drizzle)))
2566
if (ret == DRIZZLE_RETURN_OK &&
2567
drizzle_result_buffer(&res) == DRIZZLE_RETURN_OK)
2569
drizzle_row_t row= drizzle_row_next(&res);
2571
current_db= strdup(row[0]);
2572
drizzle_result_free(&res);
2457
DRIZZLE_ROW row= drizzle_fetch_row(res);
2459
current_db= strdup(row[0]);
2460
drizzle_free_result(res);
2577
2464
/***************************************************************************
2578
The different commands
2579
***************************************************************************/
2465
The different commands
2466
***************************************************************************/
2581
int drizzleclient_real_query_for_lazy(const char *buf, int length,
2582
drizzle_result_st *result,
2583
uint32_t *error_code)
2468
int drizzle_real_query_for_lazy(const char *buf, int length)
2585
drizzle_return_t ret;
2587
for (uint32_t retry=0;; retry++)
2470
for (uint retry=0;; retry++)
2590
if (drizzle_query(&con,result,buf,length,&ret) != NULL &&
2591
ret == DRIZZLE_RETURN_OK)
2473
if (!drizzle_real_query(&drizzle,buf,length))
2595
error= put_error(&con, result);
2597
if (ret == DRIZZLE_RETURN_ERROR_CODE)
2599
*error_code= drizzle_result_error_code(result);
2600
drizzle_result_free(result);
2603
if (ret != DRIZZLE_RETURN_SERVER_GONE || retry > 1 ||
2475
error= put_error(&drizzle);
2476
if (drizzle_errno(&drizzle) != CR_SERVER_GONE_ERROR || retry > 1 ||
2604
2477
!opt_reconnect)
2609
2479
if (reconnect())
2614
int drizzleclient_store_result_for_lazy(drizzle_result_st *result)
2484
int drizzle_store_result_for_lazy(DRIZZLE_RES **result)
2616
if (drizzle_result_buffer(result) == DRIZZLE_RETURN_OK)
2486
if ((*result=drizzle_store_result(&drizzle)))
2619
if (drizzle_con_error(&con)[0])
2621
int ret = put_error(&con, result);
2622
drizzle_result_free(result);
2489
if (drizzle_error(&drizzle)[0])
2490
return put_error(&drizzle);
2494
static void print_help_item(DRIZZLE_ROW *cur, int num_name, int num_cat, char *last_char)
2496
char ccat= (*cur)[num_cat][0];
2497
if (*last_char != ccat)
2499
put_info(ccat == 'Y' ? _("categories:") : _("topics:"), INFO_INFO,0,0);
2502
tee_fprintf(PAGER, " %s\n", (*cur)[num_name]);
2506
static int com_server_help(string *buffer,
2507
const char *line __attribute__((unused)),
2511
const char *server_cmd= buffer->c_str();
2513
DRIZZLE_RES *result;
2516
if (help_arg[0] != '\'')
2518
char *end_arg= strchr(help_arg, '\0');
2521
while (my_isspace(charset_info,*end_arg))
2525
(void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS);
2526
server_cmd= cmd_buf;
2529
if (!connected && reconnect())
2532
if ((error= drizzle_real_query_for_lazy(server_cmd,(int)strlen(server_cmd))) ||
2533
(error= drizzle_store_result_for_lazy(&result)))
2538
unsigned int num_fields= drizzle_num_fields(result);
2539
uint64_t num_rows= drizzle_num_rows(result);
2540
drizzle_fetch_fields(result);
2541
if (num_fields==3 && num_rows==1)
2543
if (!(cur= drizzle_fetch_row(result)))
2550
tee_fprintf(PAGER, _("Name: \'%s\'\n"), cur[0]);
2551
tee_fprintf(PAGER, _("Description:\n%s"), cur[1]);
2552
if (cur[2] && *((char*)cur[2]))
2553
tee_fprintf(PAGER, _("Examples:\n%s"), cur[2]);
2554
tee_fprintf(PAGER, "\n");
2557
else if (num_fields >= 2 && num_rows)
2562
int num_name= 0, num_cat= 0;
2564
if (num_fields == 2)
2566
put_info(_("Many help items for your request exist."), INFO_INFO,0,0);
2567
put_info(_("To make a more specific request, please type 'help <item>',\nwhere <item> is one of the following"), INFO_INFO,0,0);
2571
else if ((cur= drizzle_fetch_row(result)))
2573
tee_fprintf(PAGER, _("You asked for help about help category: '%s'\n"), cur[0]);
2574
put_info(_("For more information, type 'help <item>', where <item> is one of the following"), INFO_INFO,0,0);
2577
print_help_item(&cur,1,2,&last_char);
2580
while ((cur= drizzle_fetch_row(result)))
2581
print_help_item(&cur,num_name,num_cat,&last_char);
2582
tee_fprintf(PAGER, "\n");
2587
put_info(_("\nNothing found"), INFO_INFO,0,0);
2588
put_info(_("Please try to run 'help contents' for a list of all accessible topics\n"), INFO_INFO,0,0);
2593
drizzle_free_result(result);
2629
com_help(string *buffer, const char *)
2598
com_help(string *buffer __attribute__((unused)),
2599
const char *line __attribute__((unused)))
2631
2601
register int i, j;
2632
char buff[32], *end;
2602
char * help_arg= strchr(line,' '), buff[32], *end;
2605
while (my_isspace(charset_info,*help_arg))
2607
if (*help_arg) return com_server_help(buffer,line,help_arg);
2634
2610
put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0);
2635
2611
if (!named_cmds)
2636
2612
put_info(_("Note that all text commands must be first on line and end with ';'"),INFO_INFO,0,0);
2637
2613
for (i = 0; commands[i].name; i++)
2639
end= strcpy(buff, commands[i].name);
2640
end+= strlen(commands[i].name);
2615
end= stpcpy(buff, commands[i].name);
2641
2616
for (j= (int)strlen(commands[i].name); j < 10; j++)
2642
end= strcpy(end, " ")+1;
2617
end= stpcpy(end, " ");
2643
2618
if (commands[i].func)
2644
2619
tee_fprintf(stdout, "%s(\\%c) %s\n", buff,
2645
2620
commands[i].cmd_char, _(commands[i].doc));
2647
tee_fprintf(stdout, "\n");
2622
if (connected && drizzle_get_server_version(&drizzle) >= 40100)
2623
put_info(_("\nFor server side help, type 'help contents'\n"), INFO_INFO,0,0);
2654
com_clear(string *buffer, const char *)
2629
com_clear(string *buffer,
2630
const char *line __attribute__((unused)))
2656
2632
if (status.add_to_history)
2657
2633
fix_history(buffer);