summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2016-04-28 11:10:55 +0300
committerMonty <monty@mariadb.org>2016-04-28 13:39:55 +0300
commitb4ff64568c88ab3ce559e7bd39853d9cbf86704a (patch)
tree1eff90ae44fc8b7e8e224844c087add4e561ebb5 /sql/sql_show.cc
parent7c6cb41b15624fa77cbc92c7b5de9a834e011d56 (diff)
downloadmariadb-git-b4ff64568c88ab3ce559e7bd39853d9cbf86704a.tar.gz
Fixed wrong counting of global Memory_used
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 4a30b68bbc0..1cbad7e9ea0 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2961,8 +2961,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
thread in this thread. However it's better that we notice it eventually
than hide it.
*/
- table->field[12]->store((longlong) (tmp->status_var.local_memory_used +
- sizeof(THD)),
+ table->field[12]->store((longlong) tmp->status_var.local_memory_used,
FALSE);
table->field[12]->set_notnull();
table->field[13]->store((longlong) tmp->get_examined_row_count(), TRUE);
@@ -3258,7 +3257,8 @@ static bool show_status_array(THD *thd, const char *wild,
*/
for (var=variables; var->type == SHOW_FUNC ||
var->type == SHOW_SIMPLE_FUNC; var= &tmp)
- ((mysql_show_var_func)(var->value))(thd, &tmp, buff, scope);
+ ((mysql_show_var_func)(var->value))(thd, &tmp, buff,
+ status_var, scope);
SHOW_TYPE show_type=var->type;
if (show_type == SHOW_ARRAY)
@@ -3390,10 +3390,14 @@ end:
DBUG_RETURN(res);
}
-/* collect status for all running threads */
+/*
+ collect status for all running threads
+ Return number of threads used
+*/
-void calc_sum_of_all_status(STATUS_VAR *to)
+uint calc_sum_of_all_status(STATUS_VAR *to)
{
+ uint count= 0;
DBUG_ENTER("calc_sum_of_all_status");
/* Ensure that thread id not killed during loop */
@@ -3404,16 +3408,21 @@ void calc_sum_of_all_status(STATUS_VAR *to)
/* Get global values as base */
*to= global_status_var;
+ to->local_memory_used= 0;
/* Add to this status from existing threads */
while ((tmp= it++))
{
+ count++;
if (!tmp->status_in_global)
+ {
add_to_status(to, &tmp->status_var);
+ to->local_memory_used+= tmp->status_var.local_memory_used;
+ }
}
mysql_mutex_unlock(&LOCK_thread_count);
- DBUG_VOID_RETURN;
+ DBUG_RETURN(count);
}