Commit 8ea529ec authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-29131 Assertion `status == 0' failed when renaming user after deleting table roles_mapping

if mysql.roles_mapping table doesn't exist (it's optional, after all),
we still update in-memory structures to keep them consistent
parent 6c7e3e5c
...@@ -25,3 +25,12 @@ newhost test_user_rm test_role1 N ...@@ -25,3 +25,12 @@ newhost test_user_rm test_role1 N
delete from mysql.roles_mapping; delete from mysql.roles_mapping;
delete from mysql.user where user like 'test%'; delete from mysql.user where user like 'test%';
flush privileges; flush privileges;
#
# MDEV-29131 Assertion `status == 0' failed when renaming user after deleting table roles_mapping
#
create role r;
rename table mysql.roles_mapping to test.t1;
rename user current_user to a@a;
rename user a@a to root@localhost;
rename table test.t1 to mysql.roles_mapping;
drop role r;
...@@ -36,3 +36,13 @@ delete from mysql.roles_mapping; ...@@ -36,3 +36,13 @@ delete from mysql.roles_mapping;
delete from mysql.user where user like 'test%'; delete from mysql.user where user like 'test%';
flush privileges; flush privileges;
--echo #
--echo # MDEV-29131 Assertion `status == 0' failed when renaming user after deleting table roles_mapping
--echo #
create role r;
rename table mysql.roles_mapping to test.t1;
rename user current_user to a@a;
rename user a@a to root@localhost;
rename table test.t1 to mysql.roles_mapping;
drop role r;
...@@ -10153,24 +10153,21 @@ static int handle_grant_data(THD *thd, Grant_tables& tables, bool drop, ...@@ -10153,24 +10153,21 @@ static int handle_grant_data(THD *thd, Grant_tables& tables, bool drop,
} }
/* Handle roles_mapping table. */ /* Handle roles_mapping table. */
if (tables.roles_mapping_table().table_exists()) if (tables.roles_mapping_table().table_exists() &&
(found= handle_grant_table(thd, tables.roles_mapping_table(),
ROLES_MAPPING_TABLE, drop, user_from, user_to)) < 0)
{ {
if ((found= handle_grant_table(thd, tables.roles_mapping_table(), /* Handle of table failed, don't touch the in-memory array. */
ROLES_MAPPING_TABLE, drop, result= -1;
user_from, user_to)) < 0) }
{ else
/* Handle of table failed, don't touch the in-memory array. */ {
result= -1; /* Handle acl_roles_mappings array */
} if ((handle_grant_struct(ROLES_MAPPINGS_HASH, drop, user_from, user_to) || found)
else && ! result)
{ result= 1; /* At least one record/element found */
/* Handle acl_roles_mappings array */ if (search_only)
if ((handle_grant_struct(ROLES_MAPPINGS_HASH, drop, user_from, user_to) || found) goto end;
&& ! result)
result= 1; /* At least one record/element found */
if (search_only)
goto end;
}
} }
/* Handle user table. */ /* Handle user table. */
......
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