diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fec7e5ab20d..4124db36b7f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1059,7 +1059,7 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, Vio* save_vio; ulong save_client_capabilities; - thd->proc_info= "Execution of init_command"; + THD_PROC_INFO(thd, "Execution of init_command"); /* We need to lock init_command_var because during execution of init_command_var query @@ -1159,7 +1159,7 @@ pthread_handler_t handle_one_connection(void *arg) net->compress=1; // Use compression thd->version= refresh_version; - thd->proc_info= 0; + THD_PROC_INFO(thd, 0); thd->command= COM_SLEEP; thd->set_time(); thd->init_for_queries(); @@ -1176,7 +1176,7 @@ pthread_handler_t handle_one_connection(void *arg) sctx->host_or_ip, "init_connect command failed"); sql_print_warning("%s", net->last_error); } - thd->proc_info=0; + THD_PROC_INFO(thd, 0); thd->set_time(); thd->init_for_queries(); } @@ -1259,7 +1259,7 @@ pthread_handler_t handle_bootstrap(void *arg) if (thd->variables.max_join_size == HA_POS_ERROR) thd->options |= OPTION_BIG_SELECTS; - thd->proc_info=0; + THD_PROC_INFO(thd, 0); thd->version=refresh_version; thd->security_ctx->priv_user= thd->security_ctx->user= (char*) my_strdup("boot", MYF(MY_WME)); @@ -2106,7 +2106,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (thd->lock || thd->open_tables || thd->derived_tables || thd->prelocked_mode) { - thd->proc_info="closing tables"; + THD_PROC_INFO(thd, "closing tables"); close_thread_tables(thd); /* Free tables */ } /* @@ -2129,9 +2129,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, log_slow_statement(thd); - thd->proc_info="cleaning up"; + THD_PROC_INFO(thd, "cleaning up"); VOID(pthread_mutex_lock(&LOCK_thread_count)); // For process list - thd->proc_info=0; + THD_PROC_INFO(thd, 0); thd->command=COM_SLEEP; thd->query=0; thd->query_length=0; @@ -2164,8 +2164,6 @@ void log_slow_statement(THD *thd) */ if (thd->enable_slow_log && !thd->user_time) { - thd->proc_info="logging slow query"; - if ((ulong) (thd->start_time - thd->time_after_lock) > thd->variables.long_query_time || (thd->server_status & @@ -2174,6 +2172,7 @@ void log_slow_statement(THD *thd) /* == SQLCOM_END unless this is a SHOW command */ thd->lex->orig_sql_command == SQLCOM_END) { + THD_PROC_INFO(thd, "logging slow query"); thd->status_var.long_query_count++; mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query); } @@ -2697,6 +2696,20 @@ mysql_execute_command(THD *thd) (1L << (uint) MYSQL_ERROR::WARN_LEVEL_ERROR)); break; } + case SQLCOM_SHOW_PROFILES: + { + thd->profiling.store(); + thd->profiling.discard(); + res= thd->profiling.show_profiles(); + break; + } + case SQLCOM_SHOW_PROFILE: + { + thd->profiling.store(); + thd->profiling.discard(); // will get re-enabled by reset() + res= thd->profiling.show_last(lex->profile_options); + break; + } case SQLCOM_SHOW_NEW_MASTER: { if (check_global_access(thd, REPL_SLAVE_ACL)) @@ -3544,7 +3557,7 @@ end_with_restore_list: if (add_item_to_list(thd, new Item_null())) goto error; - thd->proc_info="init"; + THD_PROC_INFO(thd, "init"); if ((res= open_and_lock_tables(thd, all_tables))) break; @@ -4972,7 +4985,7 @@ end_with_restore_list: send_ok(thd); break; } - thd->proc_info="query end"; + THD_PROC_INFO(thd, "query end"); /* Two binlog-related cleanups: */ /* @@ -5143,6 +5156,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, else save_priv= &dummy; + THD_PROC_INFO(thd, "checking permissions"); + if ((!db || !db[0]) && !thd->db && !dont_check_global_grants) { DBUG_PRINT("error",("No database")); @@ -5630,6 +5645,7 @@ void mysql_reset_thd_for_next_command(THD *thd) thd->total_warn_count=0; // Warnings for this query thd->rand_used= 0; thd->sent_row_count= thd->examined_row_count= 0; + thd->profiling.reset(); } DBUG_VOID_RETURN; } @@ -5853,7 +5869,7 @@ void mysql_parse(THD *thd, char *inBuf, uint length) query_cache_abort(&thd->net); lex->unit.cleanup(); } - thd->proc_info="freeing items"; + THD_PROC_INFO(thd, "freeing items"); thd->end_statement(); thd->cleanup_after_query(); DBUG_ASSERT(thd->change_list.is_empty()); |