Commit 0357791e authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

MDEV-8280: crash in 'show global status' with --skip-grant-tables

The crash was caused by attempting to use a hashtable without
it getting initialized, due to the --skip-grant-tables switch.
parent cbb8b2d0
......@@ -80,3 +80,14 @@ End of 5.0 tests
select no_such_function(1);
ERROR 42000: FUNCTION test.no_such_function does not exist
End of 5.1 tests
show global status like 'Acl%';
Variable_name Value
Acl_column_grants 0
Acl_database_grants 0
Acl_function_grants 0
Acl_procedure_grants 0
Acl_proxy_users 0
Acl_role_grants 0
Acl_roles 0
Acl_table_grants 0
Acl_users 0
......@@ -132,3 +132,8 @@ select count(*) from information_schema.USER_PRIVILEGES;
select no_such_function(1);
--echo End of 5.1 tests
#
# MDEV-8280 crash in 'show global status' with --skip-grant-tables
#
show global status like 'Acl%';
......@@ -10383,11 +10383,14 @@ static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff,
var->type= SHOW_ULONG;
var->value= buff;
*(ulong *)buff= 0;
if (initialized)
{
mysql_rwlock_rdlock(&LOCK_grant);
mysql_mutex_lock(&acl_cache->lock);
my_hash_iterate(&column_priv_hash, count_column_grants, buff);
mysql_mutex_unlock(&acl_cache->lock);
mysql_rwlock_unlock(&LOCK_grant);
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment