Skip to content

Commit

Permalink
MDEV-30526 Assertion `rights == merged->cols' failed in update_role_c…
Browse files Browse the repository at this point in the history
…olumns

another case of the antipattern "iterate the HASH and delete
elements as we go"
  • Loading branch information
vuvova committed Feb 21, 2023
1 parent 3c6f108 commit 2e6a988
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mysql-test/suite/roles/role_grant_propagate.result
Expand Up @@ -163,5 +163,18 @@ drop role student;
drop role admin;
drop database crm;
#
# MDEV-30526 Assertion `rights == merged->cols' failed in update_role_columns
#
create table t1 ( pk int, i int);
create role a;
grant select (i), update (pk) on t1 to a;
revoke update (pk) on t1 from a;
show grants for a;
Grants for a
GRANT USAGE ON *.* TO `a`
GRANT SELECT (`i`) ON `test`.`t1` TO `a`
drop role a;
drop table t1;
#
# End of 10.3 tests
#
11 changes: 11 additions & 0 deletions mysql-test/suite/roles/role_grant_propagate.test
Expand Up @@ -196,6 +196,17 @@ drop role student;
drop role admin;
drop database crm;

--echo #
--echo # MDEV-30526 Assertion `rights == merged->cols' failed in update_role_columns
--echo #
create table t1 ( pk int, i int);
create role a;
grant select (i), update (pk) on t1 to a;
revoke update (pk) on t1 from a;
show grants for a;
drop role a;
drop table t1;

--echo #
--echo # End of 10.3 tests
--echo #
2 changes: 2 additions & 0 deletions sql/sql_acl.cc
Expand Up @@ -6550,6 +6550,7 @@ static int update_role_columns(GRANT_TABLE *merged,
}
}

restart:
for (uint i=0 ; i < mh->records ; i++)
{
GRANT_COLUMN *col = (GRANT_COLUMN *)my_hash_element(mh, i);
Expand All @@ -6558,6 +6559,7 @@ static int update_role_columns(GRANT_TABLE *merged,
{
changed= 1;
my_hash_delete(mh, (uchar*)col);
goto restart;
}
}
DBUG_ASSERT(rights == merged->cols);
Expand Down

0 comments on commit 2e6a988

Please sign in to comment.