summaryrefslogtreecommitdiff
path: root/client/mysqltest.cc
diff options
context:
space:
mode:
authorBjorn Munch <bjorn.munch@oracle.com>2011-09-15 13:09:24 +0200
committerBjorn Munch <bjorn.munch@oracle.com>2011-09-15 13:09:24 +0200
commit04c402c452c4fc124cf30e6ac2b87b62ddc4e579 (patch)
tree041c31b29aa104d98407ddddca490a5f66d2390e /client/mysqltest.cc
parente0a9cd56a76d4dfcf797e5a0186f53405f0b7fef (diff)
parente24d8bbf0af4d1312f431cf5274fd0fa38646d9f (diff)
downloadmariadb-git-04c402c452c4fc124cf30e6ac2b87b62ddc4e579.tar.gz
upmerge 12793118,12912120
Diffstat (limited to 'client/mysqltest.cc')
-rw-r--r--client/mysqltest.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 806f35bb85a..1661385162c 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -498,6 +498,7 @@ TYPELIB command_typelib= {array_elements(command_names),"",
DYNAMIC_STRING ds_res;
/* Points to ds_warning in run_query, so it can be freed */
DYNAMIC_STRING *ds_warn= 0;
+struct st_command *curr_command= 0;
char builtin_echo[FN_REFLEN];
@@ -2400,9 +2401,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);
@@ -2556,8 +2564,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);
@@ -8555,6 +8570,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);