diff options
author | Bjorn Munch <Bjorn.Munch@sun.com> | 2010-02-09 18:13:57 +0100 |
---|---|---|
committer | Bjorn Munch <Bjorn.Munch@sun.com> | 2010-02-09 18:13:57 +0100 |
commit | 0ad9a5992d0832b07beaa5326d4d53e36669184d (patch) | |
tree | 5fb7bdbbd2fc2f86c74c329eea8b3fc39c7ef47e /client | |
parent | 97219cb9ef0edfed4679e92ce55a2f980e784eed (diff) | |
download | mariadb-git-0ad9a5992d0832b07beaa5326d4d53e36669184d.tar.gz |
Bug #50618 Please allow 'sleep $variable' in mtr
Made mtr's sleep function understand $variables
A few fixes since previous patch, added tests
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index d2ee5855d26..539b5ccae5f 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -491,6 +491,8 @@ void free_replace(); void do_get_replace_regex(struct st_command *command); void free_replace_regex(); +/* Used by sleep */ +void check_eol_junk_line(const char *eol); void free_all_replace(){ free_replace(); @@ -1045,7 +1047,7 @@ void check_command_args(struct st_command *command, } /* Check for too many arguments passed */ ptr= command->last_argument; - while(ptr <= command->end) + while(ptr <= command->end && *ptr != '#') { if (*ptr && *ptr != ' ') die("Extra argument '%s' passed to '%.*s'", @@ -4211,10 +4213,19 @@ int do_disable_rpl_parse(struct st_command *command __attribute__((unused))) int do_sleep(struct st_command *command, my_bool real_sleep) { int error= 0; - char *p= command->first_argument; - char *sleep_start, *sleep_end= command->end; + char *sleep_start, *sleep_end; double sleep_val; + char *p; + static DYNAMIC_STRING ds_sleep; + const struct command_arg sleep_args[] = { + { "sleep_delay", ARG_STRING, TRUE, &ds_sleep, "Number of seconds to sleep." } + }; + check_command_args(command, command->first_argument, sleep_args, + sizeof(sleep_args)/sizeof(struct command_arg), + ' '); + p= ds_sleep.str; + sleep_end= ds_sleep.str + ds_sleep.length; while (my_isspace(charset_info, *p)) p++; if (!*p) @@ -4223,11 +4234,13 @@ int do_sleep(struct st_command *command, my_bool real_sleep) /* Check that arg starts with a digit, not handled by my_strtod */ if (!my_isdigit(charset_info, *sleep_start)) die("Invalid argument to %.*s \"%s\"", command->first_word_len, - command->query,command->first_argument); + command->query, sleep_start); sleep_val= my_strtod(sleep_start, &sleep_end, &error); + check_eol_junk_line(sleep_end); if (error) die("Invalid argument to %.*s \"%s\"", command->first_word_len, command->query, command->first_argument); + dynstr_free(&ds_sleep); /* Fixed sleep time selected by --sleep option */ if (opt_sleep >= 0 && !real_sleep) @@ -4236,7 +4249,6 @@ int do_sleep(struct st_command *command, my_bool real_sleep) DBUG_PRINT("info", ("sleep_val: %f", sleep_val)); if (sleep_val) my_sleep((ulong) (sleep_val * 1000000L)); - command->last_argument= sleep_end; return 0; } |