diff options
author | Elena Stepanova <elenst@ubuntu11.home> | 2012-07-16 06:14:53 +0400 |
---|---|---|
committer | Elena Stepanova <elenst@ubuntu11.home> | 2012-07-16 06:14:53 +0400 |
commit | 403cac0fe710bbd65a65f5b409cff6194ce6bace (patch) | |
tree | 8153be180c7d80b44e7b0bbf47ae8c9f7cc99e19 /client | |
parent | 49da8e7e212ec2ba739b9a7e2f512f1f71c62f1e (diff) | |
download | mariadb-git-403cac0fe710bbd65a65f5b409cff6194ce6bace.tar.gz |
Allow multiple error codes inside a variable in --error command
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.cc | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 57b7ff5fa0a..f204f359656 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5205,15 +5205,32 @@ const char *get_errname_from_code (uint error_code) void do_get_errcodes(struct st_command *command) { struct st_match_err *to= saved_expected_errors.err; - char *p= command->first_argument; - uint count= 0; - char *next; - DBUG_ENTER("do_get_errcodes"); - if (!*p) + if (!*command->first_argument) die("Missing argument(s) to 'error'"); + /* TODO: Potentially, there is a possibility of variables + being expanded twice, e.g. + + let $errcodes = 1,\$a; + let $a = 1051; + error $errcodes; + DROP TABLE unknown_table; + ... + Got one of the listed errors + + But since it requires manual escaping, it does not seem + particularly dangerous or error-prone. + */ + DYNAMIC_STRING ds; + init_dynamic_string(&ds, 0, command->query_len + 64, 256); + do_eval(&ds, command->first_argument, command->end, !is_windows); + char *p= ds.str; + + uint count= 0; + char *next; + do { char *end; @@ -5323,11 +5340,15 @@ void do_get_errcodes(struct st_command *command) } while (*p); - command->last_argument= p; + command->last_argument= command->first_argument; + while (*command->last_argument) + command->last_argument++; + to->type= ERR_EMPTY; /* End of data */ DBUG_PRINT("info", ("Expected errors: %d", count)); saved_expected_errors.count= count; + dynstr_free(&ds); DBUG_VOID_RETURN; } |