summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/roles/drop_current_role.result5
-rw-r--r--mysql-test/suite/roles/drop_current_role.test9
-rw-r--r--sql/sql_acl.cc2
3 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/suite/roles/drop_current_role.result b/mysql-test/suite/roles/drop_current_role.result
new file mode 100644
index 00000000000..79525a0ff50
--- /dev/null
+++ b/mysql-test/suite/roles/drop_current_role.result
@@ -0,0 +1,5 @@
+create role r;
+set role r;
+drop role r;
+revoke all on *.* from current_role;
+ERROR 42000: There is no such grant defined for user 'r' on host ''
diff --git a/mysql-test/suite/roles/drop_current_role.test b/mysql-test/suite/roles/drop_current_role.test
new file mode 100644
index 00000000000..1485b830eed
--- /dev/null
+++ b/mysql-test/suite/roles/drop_current_role.test
@@ -0,0 +1,9 @@
+--source include/not_embedded.inc
+#
+# MDEV-22521 Server crashes in traverse_role_graph_up or Assertion `user' fails in traverse_role_graph_impl
+#
+create role r;
+set role r;
+drop role r;
+error ER_NONEXISTING_GRANT;
+revoke all on *.* from current_role;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 7925ec58852..fee337925fc 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -4977,6 +4977,8 @@ static void propagate_role_grants(ACL_ROLE *role,
enum PRIVS_TO_MERGE::what what,
const char *db= 0, const char *name= 0)
{
+ if (!role)
+ return;
mysql_mutex_assert_owner(&acl_cache->lock);
PRIVS_TO_MERGE data= { what, db, name };