MDEV-30526 Assertion `rights == merged->cols' failed in update_role_columns

another case of the antipattern "iterate the HASH and delete
elements as we go"
This commit is contained in:
Sergei Golubchik 2023-02-01 18:56:10 +01:00
parent 3c6f108540
commit 2e6a9886a9
3 changed files with 26 additions and 0 deletions

View file

@ -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
#

View file

@ -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 #

View file

@ -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);
@ -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);