[MDEV-24486] Easier way to retrieve all users that have privileges on a specific table Created: 2020-12-24 Updated: 2023-12-28 Resolved: 2023-12-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Information Schema |
| Fix Version/s: | 11.4.1 |
| Type: | New Feature | Priority: | Blocker |
| Reporter: | Hartmut Holzgraefe | Assignee: | Oleg Smirnov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Preview_11.4 | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The purpose of the TABLE_PRIVILEGES table in INFORMATION_SCHEMA seems to be a bit misleading. It only shows those privileges that were specifically granted on the table level, but it may be taken as showing all users with privileges on a table, including those that were actually granted at the database or even the global level. Right now results from three different tables have to be combined for this, e.g. using:
|
| Comments |
| Comment by Sergei Golubchik [ 2020-12-27 ] | |||
|
INFORMATION_SCHEMA.TABLE_PRIVILEGES shows what it should. While there is no "global" and "database" privileges in the standard, it clearly says that COLUMN_PRIVILEGES should only show privileges granted on the column level, not all columns where a user has any privileges on. Following this logic TABLE_PRIVILEGES should not show privileges granted on the database or global level. I'm not closing this MDEV, as "easier way to retrieve all users that have privileges on a specific table" is still a valid request, even if it cannot be solved by the INFORMATION_SCHEMA.TABLE_PRIVILEGES table. | |||
| Comment by Michael Widenius [ 2023-10-29 ] | |||
|
Could we have this as a sys view? | |||
| Comment by Sergei Golubchik [ 2023-10-31 ] | |||
|
this is a good idea. sys schema is where various views over system informational tables are, this new view would fit quite naturally there. | |||
| Comment by Oleg Smirnov [ 2023-11-08 ] | |||
|
OK, adding a new view to sys schema seems trivial, let's just clarify the requirements. 1. What the name should the view have? I couldn't come up with anything other than ALL_TABLE_PRIVILEGES. | |||
| Comment by Sergei Golubchik [ 2023-11-08 ] | |||
|
1. May be even just TABLE_PRIVILEGES? Sys schema has a view PROCESSLIST, so it can have views with the same name as in P_S or I_S and different (but related) content. | |||
| Comment by Max Mether [ 2023-11-13 ] | |||
|
If we do this for tables, why not for all objects in the system ? | |||
| Comment by Oleg Smirnov [ 2023-11-14 ] | |||
|
Take a look at the attached maxmether, if we want to display all objects, then such filtering cannot be applied. Isn't it better to have separate views for different kinds of objects, like PROCEDURE_PRIVILEGES, TABLESPACE_PRIVILEGES etc, than to mix them all together? | |||
| Comment by Sergei Golubchik [ 2023-11-14 ] | |||
|
yes, different, modelled under standard views. but I think such an extension should be a separate task anyway | |||
| Comment by Sergei Golubchik [ 2023-11-14 ] | |||
Any suggestions how to make it less manual are welcome | |||
| Comment by Max Mether [ 2023-11-14 ] | |||
|
oleg.smirnov My point was mainly that when we design this feature we should take into account that we might want to extend this for all objects. Also for completeness sake. So that whatever we do for TABLES will look similar for other objects as well. If we need separate JIRA tickets for this we should create them. | |||
| Comment by Oleg Smirnov [ 2023-11-16 ] | |||
|
1. I put breakpoints at open_table(), readfrm(), open_table_from_share(), handler::ha_open() and couldn't see any signs that the server tries to open .frm. | |||
| Comment by Michael Widenius [ 2023-11-17 ] | |||
|
How will this work with DENY and ROLES ? | |||
| Comment by Max Mether [ 2023-11-17 ] | |||
|
Yes, both ROLES and DENY would have to be taken into account for this information to accurate. I am sure one could write a query (CTE or similar) that also gets the permissions of the ROLEs. However for DENY this will have to be taken care of in the version that DENY is introduced. | |||
| Comment by Sergei Golubchik [ 2023-11-19 ] | |||
|
DENY doesn't exist yet. Roles should already work fine, the Grantee column will show the grantee whether it's a user or a role. | |||
| Comment by Oleg Smirnov [ 2023-11-20 ] | |||
|
Double-checked: correct, roles are shown along with users in the Grantee field. | |||
| Comment by Oleg Smirnov [ 2023-11-21 ] | |||
|
Branches bb-11.4- | |||
| Comment by Alice Sherepa [ 2023-12-01 ] | |||
|
ok to push | |||
| Comment by Oleg Smirnov [ 2023-12-04 ] | |||
|
serg, can you please hint where should I push to from those two branches: bb-11.4- | |||
| Comment by Sergei Golubchik [ 2023-12-04 ] | |||
|
11.4, please | |||
| Comment by Oleg Smirnov [ 2023-12-05 ] | |||
|
Pushed to 11.4 | |||
| Comment by Oleg Smirnov [ 2023-12-07 ] | |||
|
It seems that there are no tests in v_table_privileges.test with level=GLOBAL or SCHEMA, it needs to add such ones. The name of new view should be changed to
| |||
| Comment by Oleg Smirnov [ 2023-12-08 ] | |||
|
serg, can you please review bb-11.4- | |||
| Comment by Sergei Golubchik [ 2023-12-08 ] | |||
|
d857186193b looks ok to push, thanks! | |||
| Comment by Oleg Smirnov [ 2023-12-08 ] | |||
|
The amendment is pushed to 11.4 |