mirror of
https://github.com/MariaDB/server.git
synced 2025-08-05 13:16:09 +03:00
Merge branch '10.5' into 10.6
This commit is contained in:
373
client/mysql.cc
373
client/mysql.cc
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2022, MariaDB Corporation.
|
||||
Copyright (c) 2009, 2024, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -136,7 +136,7 @@ typedef struct st_status
|
||||
ulong query_start_line;
|
||||
char *file_name;
|
||||
LINE_BUFFER *line_buff;
|
||||
bool batch,add_to_history;
|
||||
bool batch, add_to_history, sandbox;
|
||||
} STATUS;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
|
||||
vertical=0, line_numbers=1, column_names=1,opt_html=0,
|
||||
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
|
||||
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
|
||||
opt_secure_auth= 0,
|
||||
opt_secure_auth= 0,
|
||||
default_pager_set= 0, opt_sigint_ignore= 0,
|
||||
auto_vertical_output= 0,
|
||||
show_warnings= 0, executing_query= 0,
|
||||
@@ -235,7 +235,8 @@ static int com_quit(String *str,char*),
|
||||
com_rehash(String *str, char*), com_tee(String *str, char*),
|
||||
com_notee(String *str, char*), com_charset(String *str,char*),
|
||||
com_prompt(String *str, char*), com_delimiter(String *str, char*),
|
||||
com_warnings(String *str, char*), com_nowarnings(String *str, char*);
|
||||
com_warnings(String *str, char*), com_nowarnings(String *str, char*),
|
||||
com_sandbox(String *str, char*);
|
||||
|
||||
#ifdef USE_POPEN
|
||||
static int com_nopager(String *str, char*), com_pager(String *str, char*),
|
||||
@@ -283,11 +284,12 @@ typedef struct {
|
||||
|
||||
static COMMANDS commands[] = {
|
||||
{ "?", '?', com_help, 1, "Synonym for `help'." },
|
||||
{ "charset", 'C', com_charset, 1,
|
||||
"Switch to another charset. Might be needed for processing binlog with multi-byte charsets." },
|
||||
{ "clear", 'c', com_clear, 0, "Clear the current input statement."},
|
||||
{ "connect",'r', com_connect,1,
|
||||
"Reconnect to the server. Optional arguments are db and host." },
|
||||
{ "delimiter", 'd', com_delimiter, 1,
|
||||
"Set statement delimiter." },
|
||||
{ "delimiter", 'd', com_delimiter, 1, "Set statement delimiter." },
|
||||
#ifdef USE_POPEN
|
||||
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
|
||||
#endif
|
||||
@@ -300,6 +302,8 @@ static COMMANDS commands[] = {
|
||||
{ "nopager",'n', com_nopager,0, "Disable pager, print to stdout." },
|
||||
#endif
|
||||
{ "notee", 't', com_notee, 0, "Don't write into outfile." },
|
||||
{ "nowarning", 'w', com_nowarnings, 0,
|
||||
"Don't show warnings after every statement." },
|
||||
#ifdef USE_POPEN
|
||||
{ "pager", 'P', com_pager, 1,
|
||||
"Set PAGER [to_pager]. Print the query results via PAGER." },
|
||||
@@ -308,6 +312,8 @@ static COMMANDS commands[] = {
|
||||
{ "prompt", 'R', com_prompt, 1, "Change your mysql prompt."},
|
||||
{ "quit", 'q', com_quit, 0, "Quit mysql." },
|
||||
{ "rehash", '#', com_rehash, 0, "Rebuild completion hash." },
|
||||
{ "sandbox", '-', com_sandbox, 0,
|
||||
"Disallow commands that access the file system (except \\P without an argument and \\e)." },
|
||||
{ "source", '.', com_source, 1,
|
||||
"Execute an SQL script file. Takes a file name as an argument."},
|
||||
{ "status", 's', com_status, 0, "Get status information from the server."},
|
||||
@@ -318,12 +324,8 @@ static COMMANDS commands[] = {
|
||||
"Set outfile [to_outfile]. Append everything into given outfile." },
|
||||
{ "use", 'u', com_use, 1,
|
||||
"Use another database. Takes database name as argument." },
|
||||
{ "charset", 'C', com_charset, 1,
|
||||
"Switch to another charset. Might be needed for processing binlog with multi-byte charsets." },
|
||||
{ "warnings", 'W', com_warnings, 0,
|
||||
"Show warnings after every statement." },
|
||||
{ "nowarning", 'w', com_nowarnings, 0,
|
||||
"Don't show warnings after every statement." },
|
||||
/* Get bash-like expansion for some commands */
|
||||
{ "create table", 0, 0, 0, ""},
|
||||
{ "create database", 0, 0, 0, ""},
|
||||
@@ -1503,35 +1505,47 @@ static struct my_option my_long_options[] =
|
||||
0, 0, 0, 0, 0},
|
||||
{"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
|
||||
0, 0, 0, 0, 0},
|
||||
{"abort-source-on-error", OPT_ABORT_SOURCE_ON_ERROR,
|
||||
{"abort-source-on-error", 0,
|
||||
"Abort 'source filename' operations in case of errors",
|
||||
&batch_abort_on_error, &batch_abort_on_error, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"auto-rehash", OPT_AUTO_REHASH,
|
||||
{"auto-rehash", 0,
|
||||
"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.",
|
||||
&opt_rehash, &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
|
||||
0, 0},
|
||||
"and field completion, but startup and reconnecting may take a longer time.",
|
||||
&opt_rehash, &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"no-auto-rehash", 'A',
|
||||
"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.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
|
||||
{"auto-vertical-output", 0,
|
||||
"Automatically switch to vertical output mode if the result is wider "
|
||||
"than the terminal width.",
|
||||
&auto_vertical_output, &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0,
|
||||
0, 0, 0, 0, 0},
|
||||
"than the terminal width.", &auto_vertical_output, &auto_vertical_output,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"batch", 'B',
|
||||
"Don't use history file. Disable interactive behavior. (Enables --silent.)",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"binary-as-hex", 0, "Print binary data as hex", &opt_binhex, &opt_binhex,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"binary-mode", 0,
|
||||
"Binary mode allows certain character sequences to be processed as data "
|
||||
"that would otherwise be treated with a special meaning by the parser. "
|
||||
"Specifically, this switch turns off parsing of all client commands except "
|
||||
"\\C and DELIMITER in non-interactive mode (i.e., when binary mode is "
|
||||
"combined with either 1) piped input, 2) the --batch mysql option, or 3) "
|
||||
"the 'source' command). Also, in binary mode, occurrences of '\\r\\n' and "
|
||||
"ASCII '\\0' are preserved within strings, whereas by default, '\\r\\n' is "
|
||||
"translated to '\\n' and '\\0' is disallowed in user input.",
|
||||
&opt_binary_mode, &opt_binary_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"character-sets-dir", OPT_CHARSETS_DIR,
|
||||
"Directory for character set files.", &charsets_dir,
|
||||
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"column-type-info", OPT_COLUMN_TYPES, "Display column type information.",
|
||||
{"column-names", 0, "Write column names in results.",
|
||||
&column_names, &column_names, 0, GET_BOOL,
|
||||
NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"skip-column-names", 'N', "Don't write column names in results.", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"column-type-info", 0, "Display column type information.",
|
||||
&column_types_flag, &column_types_flag,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"comments", 'c', "Preserve comments. Send comments to the server."
|
||||
@@ -1541,6 +1555,16 @@ static struct my_option my_long_options[] =
|
||||
{"compress", 'C', "Use compression in server/client protocol.",
|
||||
&opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
{"connect-expired-password", 0,
|
||||
"Notify the server that this client is prepared to handle expired "
|
||||
"password sandbox mode even if --batch was specified.",
|
||||
&opt_connect_expired_password, &opt_connect_expired_password, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"connect_timeout", 0, "Number of seconds before connection timeout.",
|
||||
&opt_connect_timeout, &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG,
|
||||
0, 0, 3600*12, 0, 0, 0},
|
||||
{"database", 'D', "Database to use.", ¤t_db,
|
||||
¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef DBUG_OFF
|
||||
{"debug", '#', "This is a non-debug version. Catch this and exit.",
|
||||
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@@ -1548,70 +1572,64 @@ static struct my_option my_long_options[] =
|
||||
{"debug", '#', "Output debug log.", &default_dbug_option,
|
||||
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
|
||||
{"debug-check", 0, "Check memory and open file usage at exit.",
|
||||
&debug_check_flag, &debug_check_flag, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag,
|
||||
&debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"database", 'D', "Database to use.", ¤t_db,
|
||||
¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"default-character-set", OPT_DEFAULT_CHARSET,
|
||||
{"default-auth", 0, "Default authentication client-side plugin to use.",
|
||||
&opt_default_auth, &opt_default_auth, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"default-character-set", 0,
|
||||
"Set the default character set.", &default_charset,
|
||||
&default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"delimiter", OPT_DELIMITER, "Delimiter to be used.", &delimiter_str,
|
||||
&delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"enable-cleartext-plugin", OPT_COMPATIBILTY_CLEARTEXT_PLUGIN,
|
||||
"Obsolete option. Exists only for MySQL compatibility.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"execute", 'e', "Execute command and quit. (Disables --force and history file.)", 0,
|
||||
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"enable-cleartext-plugin", OPT_COMPATIBILTY_CLEARTEXT_PLUGIN, "Obsolete option. Exists only for MySQL compatibility.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"vertical", 'E', "Print the output of a query (rows) vertically.",
|
||||
&vertical, &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
|
||||
0},
|
||||
{"force", 'f', "Continue even if we get an SQL error. Sets abort-source-on-error to 0",
|
||||
&ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"force", 'f',
|
||||
"Continue even if we get an SQL error. Sets abort-source-on-error to 0",
|
||||
&ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"host", 'h', "Connect to host.", ¤t_host,
|
||||
¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"html", 'H', "Produce HTML output.", &opt_html, &opt_html,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"ignore-spaces", 'i', "Ignore space after function names.",
|
||||
&ignore_spaces, &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"init-command", 0,
|
||||
"SQL Command to execute when connecting to MariaDB server. Will "
|
||||
"automatically be re-executed when reconnecting.", &opt_init_command,
|
||||
&opt_init_command, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"line-numbers", 0, "Write line numbers for errors.",
|
||||
&line_numbers, &line_numbers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"skip-line-numbers", 'L', "Don't write line number for errors.", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"local-infile", OPT_LOCAL_INFILE, "Enable LOAD DATA LOCAL INFILE.",
|
||||
&opt_local_infile, &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"max-allowed-packet", 0,
|
||||
"The maximum packet length to send to or receive from server.",
|
||||
&opt_max_allowed_packet, &opt_max_allowed_packet, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 16*1024LL*1024LL, 4096, 2*1024LL*1024LL*1024LL, 0, 1024, 0},
|
||||
{"max-join-size", 0,
|
||||
"Automatic limit for rows in a join when using --safe-updates.",
|
||||
&max_join_size, &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L,
|
||||
1, ULONG_MAX, 0, 1, 0},
|
||||
{"named-commands", 'G',
|
||||
"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.",
|
||||
&named_cmds, &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
||||
0, 0},
|
||||
{"ignore-spaces", 'i', "Ignore space after function names.",
|
||||
&ignore_spaces, &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"init-command", OPT_INIT_COMMAND,
|
||||
"SQL Command to execute when connecting to MariaDB server. Will "
|
||||
"automatically be re-executed when reconnecting.",
|
||||
&opt_init_command, &opt_init_command, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.",
|
||||
&opt_local_infile, &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
&named_cmds, &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"net-buffer-length", 0,
|
||||
"The buffer size for TCP/IP and socket communication.",
|
||||
&opt_net_buffer_length, &opt_net_buffer_length, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 16384, 1024, 512*1024ULL*1024ULL, MALLOC_OVERHEAD, 1024, 0},
|
||||
{"no-beep", 'b', "Turn off beep on error.", &opt_nobeep,
|
||||
&opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"host", 'h', "Connect to host.", ¤t_host,
|
||||
¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"html", 'H', "Produce HTML output.", &opt_html, &opt_html,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"xml", 'X', "Produce XML output.", &opt_xml, &opt_xml, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.",
|
||||
&line_numbers, &line_numbers, 0, GET_BOOL,
|
||||
NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"skip-line-numbers", 'L', "Don't write line number for errors.", 0, 0, 0, GET_NO_ARG,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"unbuffered", 'n', "Flush buffer after each query.", &unbuffered,
|
||||
&unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"column-names", OPT_COLUMN_NAMES, "Write column names in results.",
|
||||
&column_names, &column_names, 0, GET_BOOL,
|
||||
NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"skip-column-names", 'N',
|
||||
"Don't write column names in results.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C).",
|
||||
&opt_sigint_ignore, &opt_sigint_ignore, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"one-database", 'o',
|
||||
"Ignore statements except those that occur while the default "
|
||||
"database is the one named at the command line.",
|
||||
@@ -1632,19 +1650,20 @@ static struct my_option my_long_options[] =
|
||||
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"plugin-dir", 0, "Directory for client-side plugins.", &opt_plugin_dir,
|
||||
&opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"port", 'P', "Port number to use for connection or 0 for default to, in "
|
||||
"order of preference, my.cnf, $MYSQL_TCP_PORT, "
|
||||
#if MYSQL_PORT_DEFAULT == 0
|
||||
"/etc/services, "
|
||||
#endif
|
||||
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
|
||||
&opt_mysql_port,
|
||||
&opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"progress-reports", OPT_REPORT_PROGRESS,
|
||||
"built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", &opt_mysql_port,
|
||||
&opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"progress-reports", 0,
|
||||
"Get progress reports for long running commands (like ALTER TABLE)",
|
||||
&opt_progress_reports, &opt_progress_reports, 0, GET_BOOL, NO_ARG, 1, 0,
|
||||
0, 0, 0, 0},
|
||||
{"prompt", OPT_PROMPT, "Set the command line prompt to this value.",
|
||||
{"prompt", 0, "Set the command line prompt to this value.",
|
||||
¤t_prompt, ¤t_prompt, 0, GET_STR_ALLOC,
|
||||
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe).",
|
||||
@@ -1655,11 +1674,27 @@ static struct my_option my_long_options[] =
|
||||
"if the output is suspended. Doesn't use history file.",
|
||||
&quick, &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"raw", 'r', "Write fields without conversion. Used with --batch.",
|
||||
&opt_raw_data, &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||
0, 0, 0},
|
||||
{"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable "
|
||||
"with --disable-reconnect. This option is enabled by default.",
|
||||
&opt_raw_data, &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"reconnect", 0, "Reconnect if the connection is lost.",
|
||||
&opt_reconnect, &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||
{"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.",
|
||||
&safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.",
|
||||
&safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"sandbox", 0, "Disallow commands that access the file system (except \\P without an argument and \\e).",
|
||||
&status.sandbox, &status.sandbox, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"secure-auth", 0, "Refuse client connecting to server if it"
|
||||
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
|
||||
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"select-limit", 0,
|
||||
"Automatic limit for SELECT when using --safe-updates.", &select_limit,
|
||||
&select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX, 0, 1, 0},
|
||||
{"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"show-warnings", 0, "Show warnings after every statement.",
|
||||
&show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"sigint-ignore", 0, "Ignore SIGINT (CTRL-C).", &opt_sigint_ignore,
|
||||
&opt_sigint_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"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, 0, 0},
|
||||
{"socket", 'S', "The socket file to use for connection.",
|
||||
@@ -1673,73 +1708,22 @@ static struct my_option my_long_options[] =
|
||||
"Does not work in batch mode. Disable with --disable-tee. "
|
||||
"This option is disabled by default.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"unbuffered", 'n', "Flush buffer after each query.", &unbuffered,
|
||||
&unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifndef DONT_ALLOW_USER_CHANGE
|
||||
{"user", 'u', "User for login if not current user.", ¤t_user,
|
||||
¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.",
|
||||
&safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.",
|
||||
&safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
|
||||
0, 0, 0, 0},
|
||||
{"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0,
|
||||
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"version", 'V', "Output version information and exit.", 0, 0, 0,
|
||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"vertical", 'E', "Print the output of a query (rows) vertically.",
|
||||
&vertical, &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"connect_timeout", OPT_CONNECT_TIMEOUT,
|
||||
"Number of seconds before connection timeout.",
|
||||
&opt_connect_timeout, &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG,
|
||||
0, 0, 3600*12, 0, 0, 0},
|
||||
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
|
||||
"The maximum packet length to send to or receive from server.",
|
||||
&opt_max_allowed_packet, &opt_max_allowed_packet, 0,
|
||||
GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
|
||||
(longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
|
||||
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
|
||||
"The buffer size for TCP/IP and socket communication.",
|
||||
&opt_net_buffer_length, &opt_net_buffer_length, 0, GET_ULONG,
|
||||
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
|
||||
{"select_limit", OPT_SELECT_LIMIT,
|
||||
"Automatic limit for SELECT when using --safe-updates.",
|
||||
&select_limit, &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L,
|
||||
1, ULONG_MAX, 0, 1, 0},
|
||||
{"max_join_size", OPT_MAX_JOIN_SIZE,
|
||||
"Automatic limit for rows in a join when using --safe-updates.",
|
||||
&max_join_size, &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L,
|
||||
1, ULONG_MAX, 0, 1, 0},
|
||||
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
|
||||
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
|
||||
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.",
|
||||
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
|
||||
&show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
{"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
|
||||
&opt_plugin_dir, &opt_plugin_dir, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"default_auth", OPT_DEFAULT_AUTH,
|
||||
"Default authentication client-side plugin to use.",
|
||||
&opt_default_auth, &opt_default_auth, 0,
|
||||
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"binary-mode", 0,
|
||||
"Binary mode allows certain character sequences to be processed as data "
|
||||
"that would otherwise be treated with a special meaning by the parser. "
|
||||
"Specifically, this switch turns off parsing of all client commands except "
|
||||
"\\C and DELIMITER in non-interactive mode (i.e., when binary mode is "
|
||||
"combined with either 1) piped input, 2) the --batch mysql option, or 3) "
|
||||
"the 'source' command). Also, in binary mode, occurrences of '\\r\\n' and "
|
||||
"ASCII '\\0' are preserved within strings, whereas by default, '\\r\\n' is "
|
||||
"translated to '\\n' and '\\0' is disallowed in user input.",
|
||||
&opt_binary_mode, &opt_binary_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"connect-expired-password", 0,
|
||||
"Notify the server that this client is prepared to handle expired "
|
||||
"password sandbox mode even if --batch was specified.",
|
||||
&opt_connect_expired_password, &opt_connect_expired_password, 0, GET_BOOL,
|
||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"xml", 'X', "Produce XML output.", &opt_xml, &opt_xml, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -2818,9 +2802,7 @@ static void initialize_readline ()
|
||||
array of matches, or NULL if there aren't any.
|
||||
*/
|
||||
|
||||
static char **new_mysql_completion(const char *text,
|
||||
int start __attribute__((unused)),
|
||||
int end __attribute__((unused)))
|
||||
static char **new_mysql_completion(const char *text, int, int)
|
||||
{
|
||||
if (!status.batch && !quick)
|
||||
#if defined(USE_NEW_READLINE_INTERFACE)
|
||||
@@ -3143,8 +3125,7 @@ static void print_help_item(MYSQL_ROW *cur, int num_name, int num_cat, char *las
|
||||
}
|
||||
|
||||
|
||||
static int com_server_help(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)), char *help_arg)
|
||||
static int com_server_help(String *buffer, char *, char *help_arg)
|
||||
{
|
||||
MYSQL_ROW cur;
|
||||
const char *server_cmd;
|
||||
@@ -3246,18 +3227,16 @@ err:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
com_help(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_help(String *buffer, char *line)
|
||||
{
|
||||
int i, j;
|
||||
char * help_arg= strchr(line,' '), buff[32], *end;
|
||||
if (help_arg)
|
||||
{
|
||||
while (my_isspace(charset_info,*help_arg))
|
||||
while (my_isspace(charset_info, *help_arg))
|
||||
help_arg++;
|
||||
if (*help_arg)
|
||||
return com_server_help(buffer,line,help_arg);
|
||||
return com_server_help(buffer, line, help_arg);
|
||||
}
|
||||
|
||||
put_info("\nGeneral information about MariaDB can be found at\n"
|
||||
@@ -3280,9 +3259,7 @@ com_help(String *buffer __attribute__((unused)),
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
com_clear(String *buffer,char *line __attribute__((unused)))
|
||||
static int com_clear(String *buffer,char *)
|
||||
{
|
||||
#ifdef HAVE_READLINE
|
||||
if (status.add_to_history)
|
||||
@@ -3292,9 +3269,7 @@ com_clear(String *buffer,char *line __attribute__((unused)))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
com_charset(String *buffer __attribute__((unused)), char *line)
|
||||
static int com_charset(String *, char *line)
|
||||
{
|
||||
char buff[256], *param;
|
||||
CHARSET_INFO * new_cs;
|
||||
@@ -3326,8 +3301,7 @@ com_charset(String *buffer __attribute__((unused)), char *line)
|
||||
*/
|
||||
|
||||
|
||||
static int
|
||||
com_go(String *buffer,char *line __attribute__((unused)))
|
||||
static int com_go(String *buffer, char *)
|
||||
{
|
||||
char buff[200]; /* about 110 chars used so far */
|
||||
char time_buff[53+3+1]; /* time max + space & parens + NUL */
|
||||
@@ -3907,9 +3881,7 @@ tee_print_sized_data(const char *data, unsigned int data_length, unsigned int to
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
print_table_data_html(MYSQL_RES *result)
|
||||
static void print_table_data_html(MYSQL_RES *result)
|
||||
{
|
||||
MYSQL_ROW cur;
|
||||
MYSQL_FIELD *field;
|
||||
@@ -4205,15 +4177,15 @@ print_tab_data(MYSQL_RES *result)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
com_tee(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_tee(String *, char *line)
|
||||
{
|
||||
char file_name[FN_REFLEN], *end, *param;
|
||||
|
||||
if (status.sandbox)
|
||||
return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0);
|
||||
if (status.batch)
|
||||
return 0;
|
||||
while (my_isspace(charset_info,*line))
|
||||
while (my_isspace(charset_info, *line))
|
||||
line++;
|
||||
if (!(param = strchr(line, ' '))) // if outfile wasn't given, use the default
|
||||
{
|
||||
@@ -4250,9 +4222,7 @@ com_tee(String *buffer __attribute__((unused)),
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
com_notee(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_notee(String *, char *)
|
||||
{
|
||||
if (opt_outfile)
|
||||
end_tee();
|
||||
@@ -4265,9 +4235,7 @@ com_notee(String *buffer __attribute__((unused)),
|
||||
*/
|
||||
|
||||
#ifdef USE_POPEN
|
||||
static int
|
||||
com_pager(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_pager(String *, char *line)
|
||||
{
|
||||
char pager_name[FN_REFLEN], *end, *param;
|
||||
|
||||
@@ -4295,6 +4263,8 @@ com_pager(String *buffer __attribute__((unused)),
|
||||
}
|
||||
else
|
||||
{
|
||||
if (status.sandbox)
|
||||
return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0);
|
||||
end= strmake_buf(pager_name, param);
|
||||
while (end > pager_name && (my_isspace(charset_info,end[-1]) ||
|
||||
my_iscntrl(charset_info,end[-1])))
|
||||
@@ -4309,9 +4279,7 @@ com_pager(String *buffer __attribute__((unused)),
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
com_nopager(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_nopager(String *, char *)
|
||||
{
|
||||
strmov(pager, "stdout");
|
||||
opt_nopager=1;
|
||||
@@ -4323,7 +4291,7 @@ com_nopager(String *buffer __attribute__((unused)),
|
||||
|
||||
#ifdef USE_POPEN
|
||||
static int
|
||||
com_edit(String *buffer,char *line __attribute__((unused)))
|
||||
com_edit(String *buffer,char *)
|
||||
{
|
||||
char filename[FN_REFLEN],buff[160];
|
||||
int fd,tmp,error;
|
||||
@@ -4370,17 +4338,15 @@ err:
|
||||
|
||||
/* If arg is given, exit without errors. This happens on command 'quit' */
|
||||
|
||||
static int
|
||||
com_quit(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_quit(String *, char *)
|
||||
{
|
||||
status.exit_status=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
com_rehash(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
com_rehash(String *,
|
||||
char *)
|
||||
{
|
||||
#ifdef HAVE_READLINE
|
||||
build_completion_hash(1, 0);
|
||||
@@ -4390,12 +4356,13 @@ com_rehash(String *buffer __attribute__((unused)),
|
||||
|
||||
|
||||
#ifdef USE_POPEN
|
||||
static int
|
||||
com_shell(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_shell(String *, char *line)
|
||||
{
|
||||
char *shell_cmd;
|
||||
|
||||
if (status.sandbox)
|
||||
return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0);
|
||||
|
||||
/* Skip space from line begin */
|
||||
while (my_isspace(charset_info, *line))
|
||||
line++;
|
||||
@@ -4418,8 +4385,7 @@ com_shell(String *buffer __attribute__((unused)),
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
com_print(String *buffer,char *line __attribute__((unused)))
|
||||
static int com_print(String *buffer,char *)
|
||||
{
|
||||
tee_puts("--------------", stdout);
|
||||
(void) tee_fputs(buffer->c_ptr(), stdout);
|
||||
@@ -4429,9 +4395,8 @@ com_print(String *buffer,char *line __attribute__((unused)))
|
||||
return 0; /* If empty buffer */
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
com_connect(String *buffer, char *line)
|
||||
|
||||
static int com_connect(String *buffer, char *line)
|
||||
{
|
||||
char *tmp, buff[256];
|
||||
my_bool save_rehash= opt_rehash;
|
||||
@@ -4484,8 +4449,7 @@ com_connect(String *buffer, char *line)
|
||||
}
|
||||
|
||||
|
||||
static int com_source(String *buffer __attribute__((unused)),
|
||||
char *line)
|
||||
static int com_source(String *, char *line)
|
||||
{
|
||||
char source_name[FN_REFLEN], *end, *param;
|
||||
LINE_BUFFER *line_buff;
|
||||
@@ -4494,6 +4458,9 @@ static int com_source(String *buffer __attribute__((unused)),
|
||||
FILE *sql_file;
|
||||
my_bool save_ignore_errors;
|
||||
|
||||
if (status.sandbox)
|
||||
return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0);
|
||||
|
||||
/* Skip space from file name */
|
||||
while (my_isspace(charset_info,*line))
|
||||
line++;
|
||||
@@ -4528,6 +4495,7 @@ static int com_source(String *buffer __attribute__((unused)),
|
||||
bfill((char*) &status,sizeof(status),(char) 0);
|
||||
|
||||
status.batch=old_status.batch; // Run in batch mode
|
||||
status.sandbox=old_status.sandbox;
|
||||
status.line_buff=line_buff;
|
||||
status.file_name=source_name;
|
||||
glob_buffer.length(0); // Empty command buffer
|
||||
@@ -4549,9 +4517,7 @@ static int com_source(String *buffer __attribute__((unused)),
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
com_delimiter(String *buffer __attribute__((unused)), char *line)
|
||||
static int com_delimiter(String *, char *line)
|
||||
{
|
||||
char buff[256], *tmp;
|
||||
|
||||
@@ -4578,9 +4544,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
com_use(String *buffer __attribute__((unused)), char *line)
|
||||
static int com_use(String *, char *line)
|
||||
{
|
||||
char *tmp, buff[FN_REFLEN + 1];
|
||||
int select_db;
|
||||
@@ -4653,18 +4617,21 @@ com_use(String *buffer __attribute__((unused)), char *line)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
com_warnings(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_sandbox(String *, char *)
|
||||
{
|
||||
status.sandbox= 1;
|
||||
put_info("Sandbox mode.", INFO_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int com_warnings(String *, char *)
|
||||
{
|
||||
show_warnings = 1;
|
||||
put_info("Show warnings enabled.",INFO_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
com_nowarnings(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_nowarnings(String *, char *)
|
||||
{
|
||||
show_warnings = 0;
|
||||
put_info("Show warnings disabled.",INFO_INFO);
|
||||
@@ -4915,10 +4882,7 @@ sql_connect(char *host,char *database,char *user,char *password,uint silent)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
com_status(String *buffer __attribute__((unused)),
|
||||
char *line __attribute__((unused)))
|
||||
static int com_status(String *, char *)
|
||||
{
|
||||
const char *status_str;
|
||||
char buff[40];
|
||||
@@ -5043,8 +5007,7 @@ select_limit, max_join_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
server_version_string(MYSQL *con)
|
||||
static const char * server_version_string(MYSQL *con)
|
||||
{
|
||||
/* Only one thread calls this, so no synchronization is needed */
|
||||
if (server_version == NULL)
|
||||
@@ -5169,8 +5132,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
put_error(MYSQL *con)
|
||||
static int put_error(MYSQL *con)
|
||||
{
|
||||
return put_info(mysql_error(con), INFO_ERROR, mysql_errno(con),
|
||||
mysql_sqlstate(con));
|
||||
@@ -5236,7 +5198,7 @@ void tee_putc(int c, FILE *file)
|
||||
|
||||
len("4294967296 days, 23 hours, 59 minutes, 60.000 seconds") -> 53
|
||||
*/
|
||||
static void nice_time(double sec,char *buff,bool part_second)
|
||||
static void nice_time(double sec, char *buff, bool part_second)
|
||||
{
|
||||
ulong tmp;
|
||||
if (sec >= 3600.0*24)
|
||||
@@ -5517,8 +5479,7 @@ static void init_username()
|
||||
}
|
||||
}
|
||||
|
||||
static int com_prompt(String *buffer __attribute__((unused)),
|
||||
char *line)
|
||||
static int com_prompt(String *, char *line)
|
||||
{
|
||||
char *ptr=strchr(line, ' ');
|
||||
prompt_counter = 0;
|
||||
|
Reference in New Issue
Block a user