summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-06-08 09:55:37 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-06-08 09:55:37 -0300
commit55eee5208cfc59e801a28487acb2dbf9881d0d57 (patch)
tree6b60200527e531181be64476beffe2c071dadc01 /client
parented7f0f3023041cc1749077ad45cd5a8bb8fa784e (diff)
parent5cbb9317ad48106ed73b62408927b8a7678d0554 (diff)
downloadmariadb-git-55eee5208cfc59e801a28487acb2dbf9881d0d57.tar.gz
Merge from 5.1 main.
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc60
1 files changed, 56 insertions, 4 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 7f9bb51bd56..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 */
@@ -1798,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 */
@@ -2895,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
@@ -4550,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);
@@ -7684,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: