diff options
author | Sergei Golubchik <sergii@pisem.net> | 2010-11-05 10:59:51 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2010-11-05 10:59:51 +0100 |
commit | bc2e383e4a0dbc1949d5b65102e843c01237e23c (patch) | |
tree | 23bb774ead6f6cc840c11c0536f3f59c5d417aca /client/mysqltest.cc | |
parent | 4cce72a9292c98fab5628adc24c1635e315444e7 (diff) | |
parent | 4cfa91f42c4cde9c35979cd2b9837cb60213d876 (diff) | |
download | mariadb-git-bc2e383e4a0dbc1949d5b65102e843c01237e23c.tar.gz |
mysql-5.1 -> mysql-5.5 merge
Diffstat (limited to 'client/mysqltest.cc')
-rw-r--r-- | client/mysqltest.cc | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index ceea5486492..611f7f02be4 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -112,6 +112,7 @@ static my_bool parsing_disabled= 0; static my_bool display_result_vertically= FALSE, display_result_lower= FALSE, display_metadata= FALSE, display_result_sorted= FALSE; static my_bool disable_query_log= 0, disable_result_log= 0; +static my_bool disable_connect_log= 1; static my_bool disable_warnings= 0; static my_bool disable_info= 1; static my_bool abort_on_error= 1; @@ -257,6 +258,7 @@ struct st_connection pthread_mutex_t result_mutex; pthread_cond_t result_cond; int query_done; + my_bool has_thread; #endif /*EMBEDDED_LIBRARY*/ }; @@ -286,6 +288,7 @@ enum enum_commands { Q_EVAL_RESULT, Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, + Q_ENABLE_CONNECT_LOG, Q_DISABLE_CONNECT_LOG, Q_WAIT_FOR_SLAVE_TO_STOP, Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, Q_ENABLE_INFO, Q_DISABLE_INFO, @@ -351,6 +354,8 @@ const char *command_names[]= /* Enable/disable that the _result_ from a query is logged to result file */ "enable_result_log", "disable_result_log", + "enable_connect_log", + "disable_connect_log", "wait_for_slave_to_stop", "enable_warnings", "disable_warnings", @@ -763,7 +768,6 @@ end_thread: return 0; } - static void wait_query_thread_done(struct st_connection *con) { DBUG_ASSERT(con->tid); @@ -805,7 +809,6 @@ static int do_send_query(struct st_connection *cn, const char *q, int q_len) return 0; } - static int do_read_query_result(struct st_connection *cn) { DBUG_ASSERT(cn->tid); @@ -844,7 +847,6 @@ static void init_connection_thd(struct st_connection *cn) die("Error in the thread library"); } - #else /*EMBEDDED_LIBRARY*/ #define do_send_query(cn,q,q_len) mysql_send_query(&cn->mysql, q, q_len) @@ -2267,8 +2269,14 @@ void var_query_set(VAR *var, const char *query, const char** query_end) DBUG_ENTER("var_query_set"); LINT_INIT(res); + /* Only white space or ) allowed past ending ` */ while (end > query && *end != '`') + { + if (*end && (*end != ' ' && *end != '\t' && *end != '\n' && *end != ')')) + die("Spurious text after `query` expression"); --end; + } + if (query == end) die("Syntax error in query, missing '`'"); ++query; @@ -3982,7 +3990,18 @@ void do_perl(struct st_command *command) if (!error) my_delete(temp_file_path, MYF(0)); - handle_command_error(command, WEXITSTATUS(error)); + /* Check for error code that indicates perl could not be started */ + int exstat= WEXITSTATUS(error); +#ifdef __WIN__ + if (exstat == 1) + /* Text must begin 'perl not found' as mtr looks for it */ + abort_not_supported_test("perl not found in path or did not start"); +#else + if (exstat == 127) + abort_not_supported_test("perl not found in path"); +#endif + else + handle_command_error(command, exstat); } dynstr_free(&ds_delimiter); DBUG_VOID_RETURN; @@ -4896,6 +4915,16 @@ void select_connection_name(const char *name) set_current_connection(con); + /* Connection logging if enabled */ + if (!disable_connect_log && !disable_query_log) + { + DYNAMIC_STRING *ds= &ds_res; + + dynstr_append_mem(ds, "connection ", 11); + replace_dynstr_append(ds, name); + dynstr_append_mem(ds, ";\n", 2); + } + DBUG_VOID_RETURN; } @@ -4983,6 +5012,16 @@ void do_close_connection(struct st_command *command) var_set_string("$CURRENT_CONNECTION", con->name); } + /* Connection logging if enabled */ + if (!disable_connect_log && !disable_query_log) + { + DYNAMIC_STRING *ds= &ds_res; + + dynstr_append_mem(ds, "disconnect ", 11); + replace_dynstr_append(ds, ds_connection.str); + dynstr_append_mem(ds, ";\n", 2); + } + DBUG_VOID_RETURN; } @@ -5117,6 +5156,13 @@ int connect_n_handle_errors(struct st_command *command, dynstr_append_mem(ds, delimiter, delimiter_length); dynstr_append_mem(ds, "\n", 1); } + /* Simlified logging if enabled */ + if (!disable_connect_log && !disable_query_log) + { + replace_dynstr_append(ds, command->query); + dynstr_append_mem(ds, ";\n", 2); + } + while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0, CLIENT_MULTI_STATEMENTS)) { @@ -7434,11 +7480,13 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) (flags & QUERY_REAP_FLAG)); DBUG_ENTER("run_query"); - init_dynamic_string(&ds_warnings, NULL, 0, 256); - if (cn->pending && (flags & QUERY_SEND_FLAG)) die ("Cannot run query on connection between send and reap"); + if (!(flags & QUERY_SEND_FLAG) && !cn->pending) + die ("Cannot reap on a connection without pending send"); + + init_dynamic_string(&ds_warnings, NULL, 0, 256); /* Evaluate query if this is an eval command */ @@ -8183,6 +8231,8 @@ int main(int argc, char **argv) case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break; case Q_ENABLE_RESULT_LOG: disable_result_log=0; break; case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; + case Q_ENABLE_CONNECT_LOG: disable_connect_log=0; break; + case Q_DISABLE_CONNECT_LOG: disable_connect_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; case Q_DISABLE_WARNINGS: disable_warnings=1; break; case Q_ENABLE_INFO: disable_info=0; break; |