diff options
author | Bjorn Munch <bjorn.munch@oracle.com> | 2011-09-14 15:19:24 +0200 |
---|---|---|
committer | Bjorn Munch <bjorn.munch@oracle.com> | 2011-09-14 15:19:24 +0200 |
commit | 52960624d350359c67a333fb09c3a93465116668 (patch) | |
tree | 1bebca1bd2e82673f57b57bdbb95f93fbbfa1130 /client | |
parent | 52d9e13ffcacee74e42bc436877f5f4eb1999e66 (diff) | |
download | mariadb-git-52960624d350359c67a333fb09c3a93465116668.tar.gz |
Bug #12793118 MYSQLTEST: --ERROR AND --DISABLE_ABORT_ON_ERROR DO NOT WORK FOR SQL IN COMMANDS
Call handle_error() instead of die() when evaluating these
Must remember "current command" with link to errors to ignore
Added test cases to mysqltest.test
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 9985b70fcbc..593bb8ea290 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -451,6 +451,7 @@ TYPELIB command_typelib= {array_elements(command_names),"", command_names, 0}; DYNAMIC_STRING ds_res; +struct st_command *curr_command= 0; char builtin_echo[FN_REFLEN]; @@ -2212,9 +2213,16 @@ void var_query_set(VAR *var, const char *query, const char** query_end) init_dynamic_string(&ds_query, 0, (end - query) + 32, 256); do_eval(&ds_query, query, end, FALSE); - if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + if (mysql_real_query(mysql, ds_query.str, ds_query.length)) + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); dynstr_free(&ds_query); @@ -2315,8 +2323,15 @@ void var_set_query_get_value(struct st_command *command, VAR *var) /* Run the query */ if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); @@ -8147,6 +8162,8 @@ int main(int argc, char **argv) { command->last_argument= command->first_argument; processed = 1; + /* Need to remember this for handle_error() */ + curr_command= command; switch (command->type) { case Q_CONNECT: do_connect(command); |