summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h48
-rw-r--r--client/mysql.cc65
-rw-r--r--client/mysql_plugin.c110
-rw-r--r--client/mysql_upgrade.c17
-rw-r--r--client/mysqladmin.cc64
-rw-r--r--client/mysqlbinlog.cc84
-rw-r--r--client/mysqlcheck.c60
-rw-r--r--client/mysqldump.c105
-rw-r--r--client/mysqlimport.c58
-rw-r--r--client/mysqlshow.c59
-rw-r--r--client/mysqlslap.c65
-rw-r--r--client/mysqltest.cc27
12 files changed, 203 insertions, 559 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index bd768d1874c..597c074c9c2 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -153,51 +153,3 @@ enum options_client
#else
#define SOCKET_PROTOCOL_TO_FORCE MYSQL_PROTOCOL_PIPE
#endif
-
-/**
- Utility function to implicitly change the connection protocol to a
- consistent value given the command line arguments. Additionally,
- warns the user that the protocol has been changed.
-
- Arguments:
- @param [in] host Name of the host to connect to
- @param [in, out] opt_protocol Location of the protocol option
- variable to update
- @param [in] new_protocol New protocol to force
-*/
-static inline void warn_protocol_override(char *host,
- uint *opt_protocol,
- uint new_protocol)
-{
- DBUG_ASSERT(new_protocol == MYSQL_PROTOCOL_TCP
- || new_protocol == SOCKET_PROTOCOL_TO_FORCE);
-
-
- if ((host == NULL
- || strncmp(host, LOCAL_HOST, sizeof(LOCAL_HOST)-1) == 0))
- {
- const char *protocol_name;
-
- if (*opt_protocol == MYSQL_PROTOCOL_DEFAULT
-#ifndef _WIN32
- && new_protocol == MYSQL_PROTOCOL_SOCKET
-#else
- && new_protocol == MYSQL_PROTOCOL_TCP
-#endif
- )
- {
- /* This is already the default behavior, do nothing */
- return;
- }
-
- protocol_name= sql_protocol_typelib.type_names[new_protocol-1];
-
- fprintf(stderr, "%s %s %s\n",
- "WARNING: Forcing protocol to ",
- protocol_name,
- " due to option specification. "
- "Please explicitly state intended protocol.");
-
- *opt_protocol = new_protocol;
- }
-}
diff --git a/client/mysql.cc b/client/mysql.cc
index eb6508903b6..70bb4514dbc 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -299,8 +299,6 @@ unsigned short terminal_width= 80;
static uint opt_protocol=0;
static const char *opt_protocol_type= "";
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
#include "sslopt-vars.h"
const char *default_dbug_option="d:t:o,/tmp/mariadb.trace";
@@ -1273,14 +1271,6 @@ int main(int argc,char *argv[])
exit(status.exit_status);
}
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(current_host, &opt_protocol, protocol_to_force);
- }
-
-
if (status.batch && !status.line_buff &&
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
{
@@ -1890,11 +1880,9 @@ static void usage(int version)
my_bool
-get_one_option(const struct my_option *opt, const char *argument, const char *filename)
+get_one_option(const struct my_option *opt, const char *argument,
+ const char *filename)
{
- /* Track when protocol is set via CLI to not force port TCP protocol override */
- static my_bool ignore_protocol_override = FALSE;
-
switch(opt->id) {
case OPT_CHARSETS_DIR:
strmake_buf(mysql_charsets_dir, argument);
@@ -1955,18 +1943,11 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
#ifndef EMBEDDED_LIBRARY
if (!argument[0])
opt_protocol= 0;
- else if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
+ else if ((opt_protocol=
+ find_type_with_warning(argument, &sql_protocol_typelib,
opt->name)) <= 0)
exit(1);
#endif
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case OPT_SERVER_ARG:
#ifdef EMBEDDED_LIBRARY
@@ -2066,13 +2047,6 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
opt_protocol_type= "pipe";
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
#endif
break;
#include <sslopt-case.h>
@@ -2085,35 +2059,17 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
mysql_end(-1);
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
case 'I':
@@ -5660,6 +5616,7 @@ static void init_username()
full_username=my_strdup(PSI_NOT_INSTRUMENTED, cur[0],MYF(MY_WME));
part_username=my_strdup(PSI_NOT_INSTRUMENTED, strtok(cur[0],"@"),MYF(MY_WME));
(void) mysql_fetch_row(result); // Read eof
+ mysql_free_result(result);
}
}
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index ad50f64d663..44abe8614e9 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -99,7 +99,7 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
plugin_data.name= 0; /* initialize name */
-
+
/*
The following operations comprise the method for enabling or disabling
a plugin. We begin by processing the command options then check the
@@ -107,15 +107,15 @@ int main(int argc,char *argv[])
--plugin-ini (if specified). If the directories are Ok, we then look
for the mysqld executable and the plugin soname. Finally, we build a
bootstrap command file for use in bootstraping the server.
-
+
If any step fails, the method issues an error message and the tool exits.
-
+
1) Parse, execute, and verify command options.
2) Check access to directories.
3) Look for mysqld executable.
4) Look for the plugin.
5) Build a bootstrap file with commands to enable or disable plugin.
-
+
*/
if ((error= process_options(argc, argv, operation)) ||
(error= check_access()) ||
@@ -123,11 +123,11 @@ int main(int argc,char *argv[])
(error= find_plugin(tp_path)) ||
(error= build_bootstrap_file(operation, bootstrap)))
goto exit;
-
+
/* Dump the bootstrap file if --verbose specified. */
if (opt_verbose && ((error= dump_bootstrap_file(bootstrap))))
goto exit;
-
+
/* Start the server in bootstrap mode and execute bootstrap commands */
error= bootstrap_server(server_path, bootstrap);
@@ -235,7 +235,7 @@ static int run_command(char* cmd, const char *mode)
#ifdef _WIN32
/**
Check to see if there are spaces in a path.
-
+
@param[in] path The Windows path to examine.
@retval int spaces found = 1, no spaces = 0
@@ -250,7 +250,7 @@ static int has_spaces(const char *path)
/**
Convert a Unix path to a Windows path.
-
+
@param[in] path The Windows path to examine.
@returns string containing path with / changed to \\
@@ -332,12 +332,12 @@ static int get_default_values()
#ifdef _WIN32
{
char *format_str= 0;
-
+
if (has_spaces(tool_path) || has_spaces(defaults_file))
format_str = "\"%s --mysqld > %s\"";
else
format_str = "%s --mysqld > %s";
-
+
snprintf(defaults_cmd, sizeof(defaults_cmd), format_str,
add_quotes(tool_path), add_quotes(defaults_file));
if (opt_verbose)
@@ -672,7 +672,7 @@ static int load_plugin_data(char *plugin_name, char *config_file)
{
reason= "Bad format in plugin configuration file.";
fclose(file_ptr);
- goto error;
+ goto error;
}
break;
}
@@ -706,7 +706,7 @@ static int load_plugin_data(char *plugin_name, char *config_file)
}
}
}
-
+
fclose(file_ptr);
return 0;
@@ -737,7 +737,7 @@ static int check_options(int argc, char **argv, char *operation)
int num_found= 0; /* number of options found (shortcut loop) */
char config_file[FN_REFLEN]; /* configuration file name */
char plugin_name[FN_REFLEN]; /* plugin name */
-
+
/* Form prefix strings for the options. */
const char *basedir_prefix = "--basedir=";
size_t basedir_len= strlen(basedir_prefix);
@@ -812,7 +812,7 @@ static int check_options(int argc, char **argv, char *operation)
return 1;
}
/* If a plugin was specified, read the config file. */
- else if (strlen(plugin_name) > 0)
+ else if (strlen(plugin_name) > 0)
{
if (load_plugin_data(plugin_name, config_file))
{
@@ -844,22 +844,22 @@ static int check_options(int argc, char **argv, char *operation)
/**
Parse, execute, and verify command options.
-
+
This method handles all of the option processing including the optional
features for displaying data (--print-defaults, --help ,etc.) that do not
result in an attempt to ENABLE or DISABLE of a plugin.
-
+
@param[in] arc Count of arguments
@param[in] argv Array of arguments
@param[out] operation Operation (ENABLE or DISABLE)
-
+
@retval int error = 1, success = 0, exit program = -1
*/
static int process_options(int argc, char *argv[], char *operation)
{
int error= 0;
-
+
/* Parse and execute command-line options */
if ((error= handle_options(&argc, &argv, my_long_options, get_one_option)))
return error;
@@ -887,7 +887,7 @@ static int process_options(int argc, char *argv[], char *operation)
opt_basedir= my_strdup(PSI_NOT_INSTRUMENTED, buff, MYF(MY_FAE));
}
}
-
+
/*
If the user did not specify the option to skip loading defaults from a
config file and the required options are not present or there was an error
@@ -922,18 +922,18 @@ static int process_options(int argc, char *argv[], char *operation)
/**
Check access
-
+
This method checks to ensure all of the directories (opt_basedir,
opt_plugin_dir, opt_datadir, and opt_plugin_ini) are accessible by
the user.
-
+
@retval int error = 1, success = 0
*/
static int check_access()
{
int error= 0;
-
+
if ((error= my_access(opt_basedir, F_OK)))
{
fprintf(stderr, "ERROR: Cannot access basedir at '%s'.\n",
@@ -1045,13 +1045,13 @@ static int find_plugin(char *tp_path)
/**
Build the bootstrap file.
-
+
Create a new file and populate it with SQL commands to ENABLE or DISABLE
the plugin via REPLACE and DELETE operations on the mysql.plugin table.
param[in] operation The type of operation (ENABLE or DISABLE)
param[out] bootstrap A FILE* pointer
-
+
@retval int error = 1, success = 0
*/
@@ -1059,7 +1059,7 @@ static int build_bootstrap_file(char *operation, char *bootstrap)
{
int error= 0;
FILE *file= 0;
-
+
/*
Perform plugin operation : ENABLE or DISABLE
@@ -1070,10 +1070,10 @@ static int build_bootstrap_file(char *operation, char *bootstrap)
<plugin_name>.ini configuration file. Once the file is built, a call to
mysqld is made in read only, bootstrap modes to read the SQL statements
and execute them.
-
+
Note: Replace was used so that if a user loads a newer version of a
library with a different library name, the new library name is
- used for symbols that match.
+ used for symbols that match.
*/
if ((error= make_tempfile(bootstrap, "sql")))
{
@@ -1120,7 +1120,7 @@ static int build_bootstrap_file(char *operation, char *bootstrap)
printf("# Disabling %s...\n", plugin_data.name);
}
}
-
+
exit:
fclose(file);
return error;
@@ -1129,11 +1129,11 @@ exit:
/**
Dump bootstrap file.
-
+
Read the contents of the bootstrap file and print it out.
-
+
@param[in] bootstrap_file Name of bootstrap file to read
-
+
@retval int error = 1, success = 0
*/
@@ -1170,7 +1170,7 @@ exit:
/**
Bootstrap the server
-
+
Create a command line sequence to launch mysqld in bootstrap mode. This
will allow mysqld to launch a minimal server instance to read and
execute SQL commands from a file piped in (the bootstrap file). We use
@@ -1191,47 +1191,39 @@ exit:
static int bootstrap_server(char *server_path, char *bootstrap_file)
{
- char bootstrap_cmd[FN_REFLEN];
+ char bootstrap_cmd[FN_REFLEN]= {0};
+ char lc_messages_dir_str[FN_REFLEN]= {0};
int error= 0;
#ifdef _WIN32
char *format_str= 0;
const char *verbose_str= NULL;
-
-
+#endif
+
+ if (opt_lc_messages_dir != NULL)
+ snprintf(lc_messages_dir_str, sizeof(lc_messages_dir_str), "--lc-messages-dir=%s",
+ opt_lc_messages_dir);
+
+#ifdef _WIN32
if (opt_verbose)
verbose_str= "--console";
else
verbose_str= "";
+
if (has_spaces(opt_datadir) || has_spaces(opt_basedir) ||
- has_spaces(bootstrap_file))
- {
- if (opt_lc_messages_dir != NULL)
- format_str= "\"%s %s --bootstrap --datadir=%s --basedir=%s --lc-messages-dir=%s <%s\"";
- else
- format_str= "\"%s %s --bootstrap --datadir=%s --basedir=%s <%s\"";
- }
+ has_spaces(bootstrap_file) || has_spaces(lc_messages_dir_str))
+ format_str= "\"%s %s --bootstrap --datadir=%s --basedir=%s %s <%s\"";
else
- {
- if (opt_lc_messages_dir != NULL)
- format_str= "\"%s %s --bootstrap --datadir=%s --basedir=%s --lc-messages-dir=%s <%s\"";
- else
- format_str= "%s %s --bootstrap --datadir=%s --basedir=%s <%s";
- }
+ format_str= "%s %s --bootstrap --datadir=%s --basedir=%s %s <%s";
+
snprintf(bootstrap_cmd, sizeof(bootstrap_cmd), format_str,
add_quotes(convert_path(server_path)), verbose_str,
add_quotes(opt_datadir), add_quotes(opt_basedir),
- add_quotes(bootstrap_file));
+ add_quotes(lc_messages_dir_str), add_quotes(bootstrap_file));
#else
- if (opt_lc_messages_dir != NULL)
- snprintf(bootstrap_cmd, sizeof(bootstrap_cmd),
- "%s --no-defaults --bootstrap --datadir=%s --basedir=%s --lc-messages-dir=%s"
- " <%s", server_path, opt_datadir, opt_basedir, opt_lc_messages_dir, bootstrap_file);
- else
- snprintf(bootstrap_cmd, sizeof(bootstrap_cmd),
- "%s --no-defaults --bootstrap --datadir=%s --basedir=%s"
- " <%s", server_path, opt_datadir, opt_basedir, bootstrap_file);
-
+ snprintf(bootstrap_cmd, sizeof(bootstrap_cmd),
+ "%s --no-defaults --bootstrap --datadir=%s --basedir=%s %s"
+ " <%s", server_path, opt_datadir, opt_basedir, lc_messages_dir_str, bootstrap_file);
#endif
/* Execute the command */
@@ -1244,6 +1236,6 @@ static int bootstrap_server(char *server_path, char *bootstrap_file)
fprintf(stderr,
"ERROR: Unexpected result from bootstrap. Error code: %d.\n",
error);
-
+
return error;
}
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 5855f9d79a7..d5c81409eaf 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -75,6 +75,8 @@ char upgrade_from_version[1024];
static my_bool opt_write_binlog;
+static void print_conn_args(const char *tool_name);
+
#define OPT_SILENT OPT_MAX_CLIENT_OPTION
static struct my_option my_long_options[]=
@@ -154,7 +156,10 @@ static struct my_option my_long_options[]=
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User for login.", &opt_user,
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"verbose", 'v', "Display more output about the process; Using it twice will print connection argument; Using it 3 times will print out all CHECK, RENAME and ALTER TABLE during the check phase.",
+ {"verbose", 'v', "Display more output about the process; Using it twice will print connection argument;"
+ "Using it 3 times will print out all CHECK, RENAME and ALTER TABLE during the check phase;"
+ "Using it 4 times (added in MariaDB 10.0.14) will also write out all mariadb-check commands used;"
+ "Using it 5 times will print all the mariadb commands used and their results while running mysql_fix_privilege_tables script.",
&opt_not_used, &opt_not_used, 0, GET_BOOL, NO_ARG, 1, 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},
@@ -209,6 +214,7 @@ static void die(const char *fmt, ...)
DBUG_ENTER("die");
/* Print the error message */
+ print_conn_args("mariadb-check");
fflush(stdout);
va_start(args, fmt);
if (fmt)
@@ -638,6 +644,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
"--database=mysql",
"--batch", /* Turns off pager etc. */
force ? "--force": "--skip-force",
+ opt_verbose >= 5 ? "--verbose" : "",
ds_res || opt_silent ? "--silent": "",
"<",
query_file_path,
@@ -873,8 +880,7 @@ static int upgrade_already_done(int silent)
"There is no need to run mariadb-upgrade again for %s.",
upgrade_from_version, version);
if (!opt_check_upgrade)
- verbose("You can use --force if you still want to run mariadb-upgrade",
- upgrade_from_version, version);
+ verbose("You can use --force if you still want to run mariadb-upgrade");
}
return 0;
}
@@ -1336,9 +1342,7 @@ static int run_sql_fix_privilege_tables(void)
dynstr_append(&ds_script, *query_ptr);
}
- run_query(ds_script.str,
- &ds_result, /* Collect result */
- TRUE);
+ run_query(ds_script.str, (opt_verbose >= 5) ? NULL : &ds_result, TRUE);
{
/*
@@ -1509,6 +1513,7 @@ int main(int argc, char **argv)
DBUG_ASSERT(phase == phases_total);
end:
+ print_conn_args("mariadb-check");
free_used_memory();
my_end(my_end_arg);
exit(0);
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 1b99b5ce085..80f99baab7d 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -54,8 +54,6 @@ static bool sql_log_bin_off= false;
static uint opt_protocol=0;
static myf error_flags; /* flags to pass to my_printf_error, like ME_BELL */
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
/*
When using extended-status relatively, ex_val_max_len is the estimated
maximum length for any relative value printed by extended-status. The
@@ -243,12 +241,9 @@ static const char *load_default_groups[]=
0 };
my_bool
-get_one_option(const struct my_option *opt, const char *argument, const char *filename)
+get_one_option(const struct my_option *opt, const char *argument,
+ const char *filename)
{
-
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
switch(opt->id) {
case 'c':
opt_count_iterations= 1;
@@ -280,13 +275,6 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
case 'W':
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
#endif
break;
case '#':
@@ -322,45 +310,19 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
}
@@ -388,13 +350,6 @@ int main(int argc,char *argv[])
temp_argv= mask_password(argc, &argv);
temp_argc= argc;
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(host, &opt_protocol, protocol_to_force);
- }
-
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
@@ -1593,7 +1548,8 @@ static void print_relative_row_vert(MYSQL_RES *result __attribute__((unused)),
llstr((tmp - last_values[row]), buff));
/* Find the minimum row length needed to output the relative value */
- if ((length=(uint) strlen(buff) > ex_val_max_len[row]) && ex_status_printed)
+ length=(uint) strlen(buff);
+ if (length > ex_val_max_len[row] && ex_status_printed)
ex_val_max_len[row] = length;
last_values[row] = tmp;
}
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index d7fc64d730a..33f0bf609ed 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -100,8 +100,6 @@ static const char *output_prefix= "";
static char **defaults_argv= 0;
static MEM_ROOT glob_root;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
#ifndef DBUG_OFF
static const char *default_dbug_option = "d:t:o,/tmp/mariadb-binlog.trace";
const char *current_dbug_option= default_dbug_option;
@@ -1817,6 +1815,11 @@ static void cleanup()
my_free_open_file_info();
load_processor.destroy();
mysql_server_end();
+ if (opt_flashback)
+ {
+ delete_dynamic(&binlog_events);
+ delete_dynamic(&events_in_stmt);
+ }
DBUG_VOID_RETURN;
}
@@ -1904,11 +1907,11 @@ static void extend_main_gtid_event_filter(Gtid_event_filter *new_filter)
}
}
-static void die()
+static void die(int err)
{
cleanup();
my_end(MY_DONT_FREE_DBUG);
- exit(1);
+ exit(err);
}
@@ -1939,7 +1942,7 @@ static my_time_t convert_str_to_timestamp(const char* str)
l_time.time_type != MYSQL_TIMESTAMP_DATETIME || status.warnings)
{
error("Incorrect date and time argument: %s", str);
- die();
+ die(1);
}
/*
Note that Feb 30th, Apr 31st cause no error messages and are mapped to
@@ -2056,13 +2059,11 @@ int parse_gtid_filter_option(
}
extern "C" my_bool
-get_one_option(const struct my_option *opt, const char *argument, const char *filename)
+get_one_option(const struct my_option *opt, const char *argument,
+ const char *filename)
{
bool tty_password=0;
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
switch (opt->id) {
#ifndef DBUG_OFF
case '#':
@@ -2110,16 +2111,8 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
- die();
+ die(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
#ifdef WHEN_FLASHBACK_REVIEW_READY
case opt_flashback_review:
@@ -2139,7 +2132,7 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
- die();
+ die(1);
}
opt_base64_output_mode= (enum_base64_output_mode)(val - 1);
break;
@@ -2160,35 +2153,17 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
print_row_event_positions_used= 1;
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
case 'v':
@@ -2289,7 +2264,7 @@ static int parse_args(int *argc, char*** argv)
if ((ho_error=handle_options(argc, argv, my_options, get_one_option)))
{
- die();
+ die(ho_error);
}
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
@@ -2322,7 +2297,7 @@ static int parse_args(int *argc, char*** argv)
quit in error. Note that any specific error messages will have
already been written.
*/
- die();
+ die(1);
}
extend_main_gtid_event_filter(position_gtid_filter);
@@ -3256,13 +3231,6 @@ int main(int argc, char** argv)
parse_args(&argc, (char***)&argv);
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(host, &opt_protocol, protocol_to_force);
- }
-
if (!argc || opt_version)
{
if (!opt_version)
@@ -3278,6 +3246,12 @@ int main(int argc, char** argv)
my_set_max_open_files(open_files_limit);
+ if (opt_flashback && opt_raw_mode)
+ {
+ error("The --raw mode is not allowed with --flashback mode");
+ die(1);
+ }
+
if (opt_flashback)
{
my_init_dynamic_array(PSI_NOT_INSTRUMENTED, &binlog_events,
@@ -3293,7 +3267,7 @@ int main(int argc, char** argv)
if (!remote_opt)
{
error("The --raw mode only works with --read-from-remote-server");
- die();
+ die(1);
}
if (one_database)
warning("The --database option is ignored in raw mode");
@@ -3315,7 +3289,7 @@ int main(int argc, char** argv)
O_WRONLY | O_BINARY, MYF(MY_WME))))
{
error("Could not create log file '%s'", result_file_name);
- die();
+ die(1);
}
}
else
@@ -3404,7 +3378,7 @@ int main(int argc, char** argv)
/* Set delimiter back to semicolon */
if (retval != ERROR_STOP)
{
- if (!stop_event_string.is_empty())
+ if (!stop_event_string.is_empty() && result_file)
fprintf(result_file, "%s", stop_event_string.ptr());
if (!opt_raw_mode && opt_flashback)
fprintf(result_file, "DELIMITER ;\n");
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 0a5a4e1a446..6076a8cddaa 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -57,8 +57,6 @@ DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds;
DYNAMIC_ARRAY views4repair;
static uint opt_protocol=0;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_FIX_NAMES };
const char *operation_name[]=
{
@@ -283,10 +281,6 @@ get_one_option(const struct my_option *opt,
const char *filename)
{
int orig_what_to_do= what_to_do;
-
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
DBUG_ENTER("get_one_option");
switch(opt->id) {
@@ -349,13 +343,6 @@ get_one_option(const struct my_option *opt,
case 'W':
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
#endif
break;
case '#':
@@ -379,45 +366,19 @@ get_one_option(const struct my_option *opt,
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
}
@@ -994,6 +955,7 @@ static int handle_request_for_tables(char *tables, size_t length,
DBUG_RETURN(1);
if (dont_quote)
{
+ DBUG_ASSERT(op);
DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
/* No backticks here as we added them before */
@@ -1240,14 +1202,6 @@ int main(int argc, char **argv)
if (get_options(&argc, &argv))
goto end1;
-
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(current_host, &opt_protocol, protocol_to_force);
- }
-
sf_leaking_memory=0; /* from now on we cleanup properly */
ret= EX_MYSQLERR;
diff --git a/client/mysqldump.c b/client/mysqldump.c
index ebfaec5e693..ffba37ef4ea 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -195,12 +195,10 @@ FILE *stderror_file=0;
static uint opt_protocol= 0;
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
/*
-Dynamic_string wrapper functions. In this file use these
-wrappers, they will terminate the process if there is
-an allocation failure.
+ Dynamic_string wrapper functions. In this file use these
+ wrappers, they will terminate the process if there is
+ an allocation failure.
*/
static void init_dynamic_string_checked(DYNAMIC_STRING *str, const char *init_str,
size_t init_alloc, size_t alloc_increment);
@@ -880,9 +878,6 @@ get_one_option(const struct my_option *opt,
const char *filename)
{
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
switch (opt->id) {
case 'p':
if (argument == disabled_my_option)
@@ -913,13 +908,6 @@ get_one_option(const struct my_option *opt,
case 'W':
#ifdef _WIN32
opt_protocol= MYSQL_PROTOCOL_PIPE;
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
#endif
break;
case 'N':
@@ -1070,49 +1058,23 @@ get_one_option(const struct my_option *opt,
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case (int) OPT_DEFAULT_CHARSET:
if (default_charset == disabled_my_option)
default_charset= (char *)mysql_universal_client_charset;
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
}
@@ -1161,19 +1123,9 @@ static int get_options(int *argc, char ***argv)
return(ho_error);
/*
- Command line options override configured protocol
- */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(current_host, &opt_protocol, protocol_to_force);
- }
-
-
- /*
- Dumping under --system=stats with --replace or --insert-ignore is safe and will not
- result into race condition. Otherwise dump only structure and ignore data by default
- while dumping.
+ Dumping under --system=stats with --replace or --insert-ignore is
+ safe and will not result into race condition. Otherwise dump only
+ structure and ignore data by default while dumping.
*/
if (!(opt_system & OPT_SYSTEM_STATS) && !(opt_ignore || opt_replace_into))
{
@@ -2645,7 +2597,10 @@ static uint dump_events_for_db(char *db)
/* Get database collation. */
if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name)))
+ {
+ mysql_free_result(event_list_res);
DBUG_RETURN(1);
+ }
}
if (switch_character_set_results(mysql, "binary"))
@@ -3498,7 +3453,10 @@ static uint get_table_structure(const char *table, const char *db, char *table_t
if (path)
{
if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))
+ {
+ mysql_free_result(result);
DBUG_RETURN(0);
+ }
write_header(sql_file, db);
}
@@ -3887,7 +3845,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
char name_buff[NAME_LEN*4+3];
char query_buff[QUERY_LENGTH];
uint old_opt_compatible_mode= opt_compatible_mode;
- MYSQL_RES *show_triggers_rs;
+ MYSQL_RES *show_triggers_rs= NULL;
MYSQL_ROW row;
FILE *sql_file= md_result_file;
@@ -3971,8 +3929,6 @@ static int dump_triggers_for_table(char *table_name, char *db_name)
}
skip:
- mysql_free_result(show_triggers_rs);
-
if (switch_character_set_results(mysql, default_charset))
goto done;
@@ -3987,7 +3943,7 @@ skip:
done:
if (path)
my_fclose(sql_file, MYF(0));
-
+ mysql_free_result(show_triggers_rs);
DBUG_RETURN(ret);
}
@@ -4108,7 +4064,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
size_t total_length, init_length;
my_bool versioned= 0;
- MYSQL_RES *res;
+ MYSQL_RES *res= NULL;
MYSQL_FIELD *field;
MYSQL_ROW row;
DBUG_ENTER("dump_table");
@@ -4322,6 +4278,8 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
my_progname_short, result_table);
error= EX_CONSCHECK;
+ if (!quick)
+ mysql_free_result(res);
goto err;
}
@@ -4640,6 +4598,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
err:
dynstr_free(&query_string);
maybe_exit(error);
+ mysql_free_result(res);
DBUG_VOID_RETURN;
} /* dump_table */
@@ -4911,7 +4870,11 @@ static int dump_all_users_roles_and_grants()
" '@', QUOTE(DEFAULT_ROLE_HOST))) as r,"
" CONCAT(QUOTE(mu.USER),'@',QUOTE(mu.HOST)) as u "
"FROM mysql.user mu LEFT JOIN mysql.default_roles using (USER, HOST)"))
+ {
+ mysql_free_result(tableres);
return 1;
+ }
+
while ((row= mysql_fetch_row(tableres)))
{
if (dump_grants(row[1]))
@@ -5996,7 +5959,8 @@ static int get_sys_var_lower_case_table_names()
lower_case_table_names= atoi(row[1]);
mysql_free_result(table_res);
}
-
+ if (!row)
+ mysql_free_result(table_res);
return lower_case_table_names;
}
@@ -6239,7 +6203,11 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
}
if (have_mariadb_gtid && get_gtid_pos(gtid_pos, 1))
+ {
+ mysql_free_result(master);
return 1;
+ }
+
}
/* SHOW MASTER STATUS reports file and position */
@@ -6361,7 +6329,10 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
{
char gtid_pos[MAX_GTID_LENGTH];
if (have_mariadb_gtid && get_gtid_pos(gtid_pos, 0))
+ {
+ mysql_free_result(slave);
return 1;
+ }
if (opt_comments)
fprintf(md_result_file, "\n--\n-- Gtid position to start replication "
"from\n--\n\n");
@@ -6557,7 +6528,7 @@ static ulong find_set(TYPELIB *lib, const char *x, size_t length,
{
const char *end= x + length;
ulong found= 0;
- uint find;
+ int find;
char buff[255];
*err_pos= 0; /* No error yet */
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 6307cd0c46e..00daec49499 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -64,8 +64,6 @@ static char * opt_mysql_unix_port=0;
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static longlong opt_ignore_lines= -1;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
#include <sslopt-vars.h>
static char **argv_to_free;
@@ -220,9 +218,6 @@ static my_bool
get_one_option(const struct my_option *opt, const char *argument,
const char *filename)
{
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
switch(opt->id) {
case 'p':
if (argument == disabled_my_option)
@@ -249,14 +244,6 @@ get_one_option(const struct my_option *opt, const char *argument,
case 'W':
opt_protocol = MYSQL_PROTOCOL_PIPE;
opt_local_file=1;
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
#endif
case OPT_MYSQL_PROTOCOL:
@@ -266,45 +253,19 @@ get_one_option(const struct my_option *opt, const char *argument,
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
case '#':
@@ -706,13 +667,6 @@ int main(int argc, char **argv)
return(1);
}
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(current_host, &opt_protocol, protocol_to_force);
- }
-
sf_leaking_memory=0; /* from now on we cleanup properly */
if (opt_use_threads && !lock_tables)
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 236fa1e25fd..c7c200fcdfd 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -41,8 +41,6 @@ static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static uint opt_protocol=0;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
static void get_options(int *argc,char ***argv);
static uint opt_mysql_port=0;
static int list_dbs(MYSQL *mysql,const char *wild);
@@ -81,14 +79,6 @@ int main(int argc, char **argv)
get_options(&argc,&argv);
-
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(host, &opt_protocol, protocol_to_force);
- }
-
sf_leaking_memory=0; /* from now on we cleanup properly */
wild=0;
if (argc)
@@ -301,9 +291,6 @@ get_one_option(const struct my_option *opt, const char *argument,
const char *filename)
{
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
switch(opt->id) {
case 'v':
opt_verbose++;
@@ -332,13 +319,6 @@ get_one_option(const struct my_option *opt, const char *argument,
case 'W':
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
#endif
break;
case OPT_MYSQL_PROTOCOL:
@@ -348,47 +328,22 @@ get_one_option(const struct my_option *opt, const char *argument,
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
+ break;
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
debug_check_flag= 1;
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 4ca69c9ed0a..54301576ba9 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -172,8 +172,6 @@ File csv_file;
static uint opt_protocol= 0;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
static int get_options(int *argc,char ***argv);
static uint opt_mysql_port= 0;
@@ -335,13 +333,6 @@ int main(int argc, char **argv)
exit(1);
}
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(host, &opt_protocol, protocol_to_force);
- }
-
sf_leaking_memory=0; /* from now on we cleanup properly */
/* Seed the random number generator if we will be using it. */
@@ -737,9 +728,6 @@ static my_bool
get_one_option(const struct my_option *opt, const char *argument,
const char *filename)
{
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
DBUG_ENTER("get_one_option");
switch(opt->id) {
case 'v':
@@ -769,13 +757,6 @@ get_one_option(const struct my_option *opt, const char *argument,
case 'W':
#ifdef _WIN32
opt_protocol= MYSQL_PROTOCOL_PIPE;
-
- /* Prioritize pipe if explicit via command line */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
#endif
break;
case OPT_MYSQL_PROTOCOL:
@@ -785,45 +766,19 @@ get_one_option(const struct my_option *opt, const char *argument,
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
case '#':
@@ -1828,6 +1783,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
uint x;
struct timeval start_time, end_time;
thread_context con;
+ int error;
pthread_t mainthread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
DBUG_ENTER("run_scheduler");
@@ -1836,8 +1792,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
con.limit= limit;
pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr,
- PTHREAD_CREATE_DETACHED);
+ if ((error= pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)))
+ {
+ printf("Got error: %d from pthread_attr_setdetachstate\n", error);
+ exit(1);
+ }
pthread_mutex_lock(&counter_mutex);
thread_counter= 0;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 75e9e913074..272c14f7635 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -3630,9 +3630,11 @@ void do_system(struct st_command *command)
/* returns TRUE if path is inside a sandbox */
bool is_sub_path(const char *path, size_t plen, const char *sandbox)
{
- size_t len= strlen(sandbox);
- if (!sandbox || !len || plen <= len || memcmp(path, sandbox, len - 1)
- || path[len] != '/')
+ size_t len;
+ if (!sandbox)
+ return false;
+ len= strlen(sandbox);
+ if (plen <= len || memcmp(path, sandbox, len-1) || path[len] != '/')
return false;
return true;
}
@@ -3878,9 +3880,21 @@ void do_move_file(struct st_command *command)
sizeof(move_file_args)/sizeof(struct command_arg),
' ');
- if (bad_path(ds_to_file.str))
- DBUG_VOID_RETURN;
+ size_t from_plen = strlen(ds_from_file.str);
+ size_t to_plen = strlen(ds_to_file.str);
+ const char *vardir= getenv("MYSQLTEST_VARDIR");
+ const char *tmpdir= getenv("MYSQL_TMP_DIR");
+ if (!((is_sub_path(ds_from_file.str, from_plen, vardir) &&
+ is_sub_path(ds_to_file.str, to_plen, vardir)) ||
+ (is_sub_path(ds_from_file.str, from_plen, tmpdir) &&
+ is_sub_path(ds_to_file.str, to_plen, tmpdir)))) {
+ report_or_die("Paths '%s' and '%s' are not both under MYSQLTEST_VARDIR '%s'"
+ "or both under MYSQL_TMP_DIR '%s'",
+ ds_from_file, ds_to_file, vardir, tmpdir);
+ DBUG_VOID_RETURN;
+ }
+
DBUG_PRINT("info", ("Move %s to %s", ds_from_file.str, ds_to_file.str));
error= (my_rename(ds_from_file.str, ds_to_file.str,
MYF(disable_warnings ? 0 : MY_WME)) != 0);
@@ -5248,6 +5262,7 @@ void do_shutdown_server(struct st_command *command)
if (!timeout || wait_until_dead(pid, timeout < 5 ? 5 : timeout))
{
(void) my_kill(pid, SIGKILL);
+ wait_until_dead(pid, 5);
}
}
DBUG_VOID_RETURN;
@@ -11883,7 +11898,7 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input,
/* Sort array */
qsort(lines.buffer, lines.elements,
- sizeof(char**), (qsort_cmp)comp_lines);
+ sizeof(uchar *), (qsort_cmp)comp_lines);
/* Create new result */
for (i= 0; i < lines.elements ; i++)