summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqltest.cc33
-rw-r--r--mysql-test/r/mysqltest.result1
-rw-r--r--mysql-test/t/mysqltest.test5
3 files changed, 33 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;
}
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 25345227d59..fdb3029059f 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -690,6 +690,7 @@ Got one of the listed errors
insert into t1 values ("Abcd");
Got one of the listed errors
garbage;
+SELECT * FROM non_existing_table;
drop table t2;
create table t1 ( f1 char(10));
insert into t1 values ("Abcd");
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index a7585bea4f8..ffbec36873e 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -2120,6 +2120,11 @@ insert into t1 values ("Abcd");
--error $errno1,ER_PARSE_ERROR
garbage;
+let $errno_multi = $errno1,ER_NO_SUCH_TABLE,$errno2,1062;
+
+--error $errno_multi
+SELECT * FROM non_existing_table;
+
drop table t2;