diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-09-16 14:03:17 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-09-16 14:03:17 +0200 |
commit | 7e29c1b53968914f42300a7f628088b99601f4db (patch) | |
tree | d9b55e33bd83a02251cd8a3fe560ef149c7b21ca /sql/sql_show.cc | |
parent | 1e3e81a6c9971a56c94086227aa438d133172863 (diff) | |
parent | 33656e042dc7e983c9612a011fdef64a8dd40aa1 (diff) | |
download | mariadb-git-7e29c1b53968914f42300a7f628088b99601f4db.tar.gz |
5.5 merge
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 87cec1ce2ae..a6d301294bf 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2290,77 +2290,77 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_VOID_RETURN; + if (thd->killed) + DBUG_VOID_RETURN; + mysql_mutex_lock(&LOCK_thread_count); // For unlink from list - if (!thd->killed) + I_List_iterator<THD> it(threads); + THD *tmp; + while ((tmp=it++)) { - I_List_iterator<THD> it(threads); - THD *tmp; - while ((tmp=it++)) + Security_context *tmp_sctx= tmp->security_ctx; + struct st_my_thread_var *mysys_var; + if ((tmp->vio_ok() || tmp->system_thread) && + (!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user)))) { - Security_context *tmp_sctx= tmp->security_ctx; - struct st_my_thread_var *mysys_var; - if ((tmp->vio_ok() || tmp->system_thread) && - (!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user)))) + thread_info *thd_info= new thread_info; + + thd_info->thread_id=tmp->thread_id; + thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user : + (tmp->system_thread ? + "system user" : "unauthenticated user")); + if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) && + thd->security_ctx->host_or_ip[0]) { - thread_info *thd_info= new thread_info; - - thd_info->thread_id=tmp->thread_id; - thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user : - (tmp->system_thread ? - "system user" : "unauthenticated user")); - if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) && - thd->security_ctx->host_or_ip[0]) - { - if ((thd_info->host= (char*) thd->alloc(LIST_PROCESS_HOST_LEN+1))) - my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN, - "%s:%u", tmp_sctx->host_or_ip, tmp->peer_port); - } - else - thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ? - tmp_sctx->host_or_ip : - tmp_sctx->host ? tmp_sctx->host : ""); - thd_info->command=(int) tmp->get_command(); - mysql_mutex_lock(&tmp->LOCK_thd_data); - if ((thd_info->db= tmp->db)) // Safe test - thd_info->db= thd->strdup(thd_info->db); - if ((mysys_var= tmp->mysys_var)) - mysql_mutex_lock(&mysys_var->mutex); - thd_info->proc_info= (char*) (tmp->killed >= KILL_QUERY ? - "Killed" : 0); - thd_info->state_info= thread_state_info(tmp); - if (mysys_var) - mysql_mutex_unlock(&mysys_var->mutex); - - /* Lock THD mutex that protects its data when looking at it. */ - if (tmp->query()) - { - uint length= MY_MIN(max_query_length, tmp->query_length()); - char *q= thd->strmake(tmp->query(),length); - /* Safety: in case strmake failed, we set length to 0. */ - thd_info->query_string= - CSET_STRING(q, q ? length : 0, tmp->query_charset()); - } + if ((thd_info->host= (char*) thd->alloc(LIST_PROCESS_HOST_LEN+1))) + my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN, + "%s:%u", tmp_sctx->host_or_ip, tmp->peer_port); + } + else + thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ? + tmp_sctx->host_or_ip : + tmp_sctx->host ? tmp_sctx->host : ""); + thd_info->command=(int) tmp->get_command(); + mysql_mutex_lock(&tmp->LOCK_thd_data); + if ((thd_info->db= tmp->db)) // Safe test + thd_info->db= thd->strdup(thd_info->db); + if ((mysys_var= tmp->mysys_var)) + mysql_mutex_lock(&mysys_var->mutex); + thd_info->proc_info= (char*) (tmp->killed >= KILL_QUERY ? + "Killed" : 0); + thd_info->state_info= thread_state_info(tmp); + if (mysys_var) + mysql_mutex_unlock(&mysys_var->mutex); - /* - Progress report. We need to do this under a lock to ensure that all - is from the same stage. - */ - if (tmp->progress.max_counter) - { - uint max_stage= MY_MAX(tmp->progress.max_stage, 1); - thd_info->progress= (((tmp->progress.stage / (double) max_stage) + - ((tmp->progress.counter / - (double) tmp->progress.max_counter) / - (double) max_stage)) * - 100.0); - set_if_smaller(thd_info->progress, 100); - } - else - thd_info->progress= 0.0; - thd_info->start_time= tmp->start_time; - mysql_mutex_unlock(&tmp->LOCK_thd_data); - thread_infos.append(thd_info); + /* Lock THD mutex that protects its data when looking at it. */ + if (tmp->query()) + { + uint length= MY_MIN(max_query_length, tmp->query_length()); + char *q= thd->strmake(tmp->query(),length); + /* Safety: in case strmake failed, we set length to 0. */ + thd_info->query_string= + CSET_STRING(q, q ? length : 0, tmp->query_charset()); } + + /* + Progress report. We need to do this under a lock to ensure that all + is from the same stage. + */ + if (tmp->progress.max_counter) + { + uint max_stage= MY_MAX(tmp->progress.max_stage, 1); + thd_info->progress= (((tmp->progress.stage / (double) max_stage) + + ((tmp->progress.counter / + (double) tmp->progress.max_counter) / + (double) max_stage)) * + 100.0); + set_if_smaller(thd_info->progress, 100); + } + else + thd_info->progress= 0.0; + thd_info->start_time= tmp->start_time; + mysql_mutex_unlock(&tmp->LOCK_thd_data); + thread_infos.append(thd_info); } } mysql_mutex_unlock(&LOCK_thread_count); @@ -7304,7 +7304,7 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) bool upper_case_names= (schema_table_idx != SCH_VARIABLES); bool sorted_vars= (schema_table_idx == SCH_VARIABLES); - if (lex->option_type == OPT_GLOBAL || + if ((sorted_vars && lex->option_type == OPT_GLOBAL) || schema_table_idx == SCH_GLOBAL_VARIABLES) option_type= OPT_GLOBAL; |