diff options
author | unknown <sanja@montyprogram.com> | 2012-05-11 11:40:23 +0300 |
---|---|---|
committer | unknown <sanja@montyprogram.com> | 2012-05-11 11:40:23 +0300 |
commit | e10fecc02f57980ddc27bafb9d1f620e8533f4a3 (patch) | |
tree | 393865dac63fb0c44cd7c6d166c97a4617b1a313 /client | |
parent | fe0a0bdb143696c54206cd5f908dac94996aab42 (diff) | |
parent | f2cbc014d98a927ed7038f55a25c3d288de10f51 (diff) | |
download | mariadb-git-e10fecc02f57980ddc27bafb9d1f620e8533f4a3.tar.gz |
Merge 5.2->5.3
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.cc | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 77fbbb1757e..612a4885303 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -743,6 +743,9 @@ void handle_error(struct st_command*, const char *err_sqlstate, DYNAMIC_STRING *ds); void handle_no_error(struct st_command*); +static void handle_no_active_connection(struct st_command* command, + struct st_connection *cn, DYNAMIC_STRING *ds); + #ifdef EMBEDDED_LIBRARY /* workaround for MySQL BUG#57491 */ @@ -2291,6 +2294,19 @@ void var_query_set(VAR *var, const char *query, const char** query_end) DBUG_ENTER("var_query_set"); LINT_INIT(res); + if (!mysql) + { + struct st_command command; + memset(&command, 0, sizeof(command)); + command.query= (char*)query; + command.first_word_len= (*query_end - query); + command.first_argument= command.query + command.first_word_len; + command.end= (char*)*query_end; + command.abort_on_error= 1; /* avoid uninitialized variables */ + handle_no_active_connection(&command, cur_con, &ds_res); + DBUG_VOID_RETURN; + } + /* Only white space or ) allowed past ending ` */ while (end > query && *end != '`') { @@ -2396,6 +2412,12 @@ void var_set_query_get_value(struct st_command *command, VAR *var) DBUG_ENTER("var_set_query_get_value"); LINT_INIT(res); + if (!mysql) + { + handle_no_active_connection(command, cur_con, &ds_res); + DBUG_VOID_RETURN; + } + strip_parentheses(command); DBUG_PRINT("info", ("query: %s", command->query)); check_command_args(command, command->first_argument, query_get_value_args, @@ -2554,6 +2576,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end, bool do_eval) command.first_word_len= len; command.first_argument= command.query + len; command.end= (char*)*p_end; + command.abort_on_error= 1; /* avoid uninitialized variables */ var_set_query_get_value(&command, v); DBUG_VOID_RETURN; } @@ -6950,6 +6973,22 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql) /* + Handle situation where query is sent but there is no active connection + (e.g directly after disconnect). + + We emulate MySQL-compatible behaviour of sending something on a closed + connection. +*/ +static void handle_no_active_connection(struct st_command *command, + struct st_connection *cn, DYNAMIC_STRING *ds) +{ + handle_error(command, 2006, "MySQL server has gone away", "000000", ds); + cn->pending= FALSE; + var_set_errno(2006); +} + + +/* Run query using MySQL C API SYNOPSIS @@ -6975,11 +7014,7 @@ void run_query_normal(struct st_connection *cn, struct st_command *command, if (!mysql) { - /* Emulate old behaviour of sending something on a closed connection */ - handle_error(command, 2006, "MySQL server has gone away", - "000000", ds); - cn->pending= FALSE; - var_set_errno(2006); + handle_no_active_connection(command, cn, ds); DBUG_VOID_RETURN; } |