pt-show-grants --include-unused-roles doesn't work as intended

Description

I tried using pt-show-grants with --include-unused-roles, but it appears the flag isn't affecting the output one way or another. Took a glance at the perl script where the option takes effect:

https://github.com/percona/percona-toolkit/blob/ff6b05b3811c8da01417444a8158c846d6240bc6/bin/pt-show-grants#L1962

Line 1962 looks like it works as it should (checking "active") however, the problem seems to lie with line 1956:

https://github.com/percona/percona-toolkit/blob/ff6b05b3811c8da01417444a8158c846d6240bc6/bin/pt-show-grants#L1956

The call is passing the list of mysql users into the second argument, so the function then attaches the list of users in the role query's WHERE clause and filters on that list, which would never be able to retrieve unused roles.

The resulting role-retrieval query is:

 

Environment

None

Smart Checklist

Activity

Show:

Lalit Choudhary January 11, 2021 at 3:13 PM

Hi

Thank you for the report.

Verified as described.

 Use of --include-unused-roles , --no-include-unused-roles option not working.{{}}

Test:

create role/users from:

https://dev.mysql.com/doc/refman/8.0/en/roles.html#roles-creating-granting

Details

Assignee

Reporter

Priority

Components

Affects versions

Smart Checklist

Created November 20, 2020 at 8:01 PM
Updated February 29, 2024 at 8:56 PM