Correct the value of global memory_used
As a special hack global memory_used isn't SHOW_LONG_STATUS but still relies on calc_sum_of_all_status() being called. followup for 63f91927870
This commit is contained in:
parent
2c0b3141f3
commit
dc6667805d
@ -74,4 +74,12 @@ DROP TRIGGER trigg1;
|
||||
DROP FUNCTION testQuestion;
|
||||
DROP EVENT ev1;
|
||||
DROP TABLE t1,t2;
|
||||
End of 6.0 tests
|
||||
#
|
||||
# End of 5.5 tests
|
||||
#
|
||||
select variable_value < 1024*1024*1024 from information_schema.global_status where variable_name='memory_used';
|
||||
variable_value < 1024*1024*1024
|
||||
1
|
||||
#
|
||||
# End of 10.2 tests
|
||||
#
|
||||
|
@ -64,5 +64,14 @@ DROP TRIGGER trigg1;
|
||||
DROP FUNCTION testQuestion;
|
||||
DROP EVENT ev1;
|
||||
DROP TABLE t1,t2;
|
||||
--echo End of 6.0 tests
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.5 tests
|
||||
--echo #
|
||||
|
||||
select variable_value < 1024*1024*1024 from information_schema.global_status where variable_name='memory_used';
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.2 tests
|
||||
--echo #
|
||||
|
||||
|
@ -8441,8 +8441,11 @@ static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff,
|
||||
var->type= SHOW_LONGLONG;
|
||||
var->value= buff;
|
||||
if (scope == OPT_GLOBAL)
|
||||
{
|
||||
calc_sum_of_all_status_if_needed(status_var);
|
||||
*(longlong*) buff= (status_var->global_memory_used +
|
||||
status_var->local_memory_used);
|
||||
}
|
||||
else
|
||||
*(longlong*) buff= status_var->local_memory_used;
|
||||
return 0;
|
||||
|
@ -865,11 +865,24 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
|
||||
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
|
||||
STATUS_VAR *dec_var);
|
||||
|
||||
uint calc_sum_of_all_status(STATUS_VAR *to);
|
||||
static inline void calc_sum_of_all_status_if_needed(STATUS_VAR *to)
|
||||
{
|
||||
if (to->local_memory_used == 0)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
*to= global_status_var;
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
calc_sum_of_all_status(to);
|
||||
DBUG_ASSERT(to->local_memory_used);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Update global_memory_used. We have to do this with atomic_add as the
|
||||
global value can change outside of LOCK_status.
|
||||
*/
|
||||
inline void update_global_memory_status(int64 size)
|
||||
static inline void update_global_memory_status(int64 size)
|
||||
{
|
||||
DBUG_PRINT("info", ("global memory_used: %lld size: %lld",
|
||||
(longlong) global_status_var.global_memory_used,
|
||||
@ -887,7 +900,7 @@ inline void update_global_memory_status(int64 size)
|
||||
@retval NULL on error
|
||||
@retval Pointter to CHARSET_INFO with the given name on success
|
||||
*/
|
||||
inline CHARSET_INFO *
|
||||
static inline CHARSET_INFO *
|
||||
mysqld_collation_get_by_name(const char *name,
|
||||
CHARSET_INFO *name_cs= system_charset_info)
|
||||
{
|
||||
@ -906,7 +919,7 @@ mysqld_collation_get_by_name(const char *name,
|
||||
return cs;
|
||||
}
|
||||
|
||||
inline bool is_supported_parser_charset(CHARSET_INFO *cs)
|
||||
static inline bool is_supported_parser_charset(CHARSET_INFO *cs)
|
||||
{
|
||||
return MY_TEST(cs->mbminlen == 1);
|
||||
}
|
||||
|
@ -3580,15 +3580,8 @@ static bool show_status_array(THD *thd, const char *wild,
|
||||
|
||||
if (show_type == SHOW_SYS)
|
||||
mysql_mutex_lock(&LOCK_global_system_variables);
|
||||
else if (show_type >= SHOW_LONG_STATUS && scope == OPT_GLOBAL &&
|
||||
!status_var->local_memory_used)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
*status_var= global_status_var;
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
calc_sum_of_all_status(status_var);
|
||||
DBUG_ASSERT(status_var->local_memory_used);
|
||||
}
|
||||
else if (show_type >= SHOW_LONG_STATUS && scope == OPT_GLOBAL)
|
||||
calc_sum_of_all_status_if_needed(status_var);
|
||||
|
||||
pos= get_one_variable(thd, var, scope, show_type, status_var,
|
||||
&charset, buff, &length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user