summaryrefslogtreecommitdiff
path: root/client/mysqltest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/mysqltest.cc')
-rw-r--r--client/mysqltest.cc102
1 files changed, 80 insertions, 22 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index fdd4ff141bc..265d3b0a8e7 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -280,6 +280,7 @@ enum enum_commands {
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
+ Q_MOVE_FILE,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
@@ -376,6 +377,7 @@ const char *command_names[]=
"list_files_append_file",
"send_shutdown",
"shutdown_server",
+ "move_file",
0
};
@@ -966,6 +968,7 @@ void check_command_args(struct st_command *command,
for (i= 0; i < num_args; i++)
{
const struct command_arg *arg= &args[i];
+ char delimiter;
switch (arg->type) {
/* A string */
@@ -974,8 +977,15 @@ void check_command_args(struct st_command *command,
while (*ptr && *ptr == ' ')
ptr++;
start= ptr;
- /* Find end of arg, terminated by "delimiter_arg" */
- while (*ptr && *ptr != delimiter_arg)
+ delimiter = delimiter_arg;
+ /* If start of arg is ' ` or " search to matching quote end instead */
+ if (*ptr && strchr ("'`\"", *ptr))
+ {
+ delimiter= *ptr;
+ start= ++ptr;
+ }
+ /* Find end of arg, terminated by "delimiter" */
+ while (*ptr && *ptr != delimiter)
ptr++;
if (ptr > start)
{
@@ -987,6 +997,11 @@ void check_command_args(struct st_command *command,
/* Empty string */
init_dynamic_string(arg->ds, "", 0, 0);
}
+ /* Find real end of arg, terminated by "delimiter_arg" */
+ /* This will do nothing if arg was not closed by quotes */
+ while (*ptr && *ptr != delimiter_arg)
+ ptr++;
+
command->last_argument= (char*)ptr;
/* Step past the delimiter */
@@ -1445,34 +1460,38 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...)
Test if diff is present. This is needed on Windows systems
as the OS returns 1 whether diff is successful or if it is
not present.
- Takes name of diff program as argument
-
+
We run diff -v and look for output in stdout.
We don't redirect stderr to stdout to make for a simplified check
Windows will output '"diff"' is not recognized... to stderr if it is
not present.
*/
-int diff_check (const char *diff_name)
+#ifdef __WIN__
+
+static int diff_check(const char *diff_name)
{
- char buf[512]= {0};
- FILE *res_file;
- char cmd[128];
- my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name);
- int have_diff = 0;
+ FILE *res_file;
+ char buf[128];
+ int have_diff= 0;
- if (!(res_file= popen(cmd, "r")))
- die("popen(\"%s\", \"r\") failed", cmd);
+ my_snprintf(buf, sizeof(buf), "%s -v", diff_name);
- /* if diff is not present, nothing will be in stdout to increment have_diff */
- if (fgets(buf, sizeof(buf), res_file))
- {
- have_diff += 1;
- }
- pclose(res_file);
- return have_diff;
+ if (!(res_file= popen(buf, "r")))
+ die("popen(\"%s\", \"r\") failed", buf);
+
+ /* if diff is not present, nothing will be in stdout to increment have_diff */
+ if (fgets(buf, sizeof(buf), res_file))
+ have_diff= 1;
+
+ pclose(res_file);
+
+ return have_diff;
}
+#endif
+
+
/*
Show the diff of two files using the systems builtin diff
command. If no such diff command exist, just dump the content
@@ -1794,7 +1813,7 @@ void check_result()
log_file.file_name(), reject_file, errno);
show_diff(NULL, result_file_name, reject_file);
- die(mess);
+ die("%s", mess);
break;
}
default: /* impossible */
@@ -2891,6 +2910,42 @@ void do_copy_file(struct st_command *command)
/*
SYNOPSIS
+ do_move_file
+ command command handle
+
+ DESCRIPTION
+ move_file <from_file> <to_file>
+ Move <from_file> to <to_file>
+*/
+
+void do_move_file(struct st_command *command)
+{
+ int error;
+ static DYNAMIC_STRING ds_from_file;
+ static DYNAMIC_STRING ds_to_file;
+ const struct command_arg move_file_args[] = {
+ { "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to move from" },
+ { "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to move to" }
+ };
+ DBUG_ENTER("do_move_file");
+
+ check_command_args(command, command->first_argument,
+ move_file_args,
+ sizeof(move_file_args)/sizeof(struct command_arg),
+ ' ');
+
+ 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(0)) != 0);
+ handle_command_error(command, error);
+ dynstr_free(&ds_from_file);
+ dynstr_free(&ds_to_file);
+ DBUG_VOID_RETURN;
+}
+
+
+/*
+ SYNOPSIS
do_chmod_file
command command handle
@@ -4546,7 +4601,7 @@ void select_connection(struct st_command *command)
};
check_command_args(command, command->first_argument, connection_args,
sizeof(connection_args)/sizeof(struct command_arg),
- ',');
+ ' ');
DBUG_PRINT("info", ("changing connection: %s", ds_connection.str));
select_connection_name(ds_connection.str);
@@ -5665,11 +5720,11 @@ static struct my_option my_long_options[] =
{"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select",
(uchar**) &sp_protocol, (uchar**) &sp_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#include "sslopt-longopts.h"
{"tail-lines", OPT_TAIL_LINES,
"Number of lines of the resul to include in a failure report",
(uchar**) &opt_tail_lines, (uchar**) &opt_tail_lines, 0,
GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0},
-#include "sslopt-longopts.h"
{"test-file", 'x', "Read test from/in this file (default stdin).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"timer-file", 'm', "File where the timing in micro seconds is stored.",
@@ -5803,6 +5858,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
}
case 'p':
+ if (argument == disabled_my_option)
+ argument= (char*) ""; // Don't require password
if (argument)
{
my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR));
@@ -7678,6 +7735,7 @@ int main(int argc, char **argv)
case Q_CHANGE_USER: do_change_user(command); break;
case Q_CAT_FILE: do_cat_file(command); break;
case Q_COPY_FILE: do_copy_file(command); break;
+ case Q_MOVE_FILE: do_move_file(command); break;
case Q_CHMOD_FILE: do_chmod_file(command); break;
case Q_PERL: do_perl(command); break;
case Q_DELIMITER: