Details
-
New Feature
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
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:
SELECT t.TABLE_SCHEMA |
, t.TABLE_NAME
|
, privs.GRANTEE
|
, GROUP_CONCAT(privs.PRIVILEGE_TYPE) AS PRIVILEGES |
FROM INFORMATION_SCHEMA.TABLES AS t |
JOIN ( SELECT NULL AS TABLE_SCHEMA |
, NULL AS TABLE_NAME |
, GRANTEE, PRIVILEGE_TYPE
|
FROM INFORMATION_SCHEMA.USER_PRIVILEGES |
|
UNION |
|
SELECT TABLE_SCHEMA |
, NULL AS TABLE_NAME |
, GRANTEE
|
, PRIVILEGE_TYPE
|
FROM INFORMATION_SCHEMA.SCHEMA_PRIVILEGES |
|
UNION |
|
SELECT TABLE_SCHEMA |
, TABLE_NAME
|
, GRANTEE
|
, PRIVILEGE_TYPE
|
FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES |
) privs
|
ON (t.TABLE_SCHEMA = privs.TABLE_SCHEMA OR privs.TABLE_SCHEMA IS NULL) |
AND (t.TABLE_NAME = privs.TABLE_NAME OR privs.TABLE_NAME IS NULL) |
AND (privs.PRIVILEGE_TYPE <> 'USAGE') |
WHERE t.TABLE_SCHEMA NOT IN ( 'mysql' |
, 'information_schema' |
, 'performance_schema' |
)
|
GROUP BY t.TABLE_SCHEMA |
, t.TABLE_NAME
|
, privs.GRANTEE
|
;
|
Attachments
Issue Links
- causes
-
MDEV-36030 sysschema.v_privileges_by_table_by_level test fails in network sandbox with hostname set to localhost
-
- Confirmed
-
- relates to
-
MDEV-32941 I_S.USER_PRIVILEGES has a wrong name and does not show roles
-
- Open
-
Activity
Field | Original Value | New Value |
---|---|---|
Assignee | Ralf Gebhardt [ ralf.gebhardt@mariadb.com ] |
Labels | need_feedback |
Labels | need_feedback |
Workflow | MariaDB v3 [ 117352 ] | MariaDB v4 [ 131427 ] |
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: {code:sql} SELECT t.TABLE_SCHEMA , t.TABLE_NAME , privs.GRANTEE , GROUP_CONCAT(privs.PRIVILEGE_TYPE) AS PRIVILEGES FROM INFORMATION_SCHEMA.TABLES AS t JOIN ( SELECT NULL AS TABLE_SCHEMA , NULL AS TABLE_NAME , GRANTEE, PRIVILEGE_TYPE FROM INFORMATION_SCHEMA.USER_PRIVILEGES UNION SELECT TABLE_SCHEMA , NULL AS TABLE_NAME , GRANTEE , PRIVILEGE_TYPE FROM INFORMATION_SCHEMA.SCHEMA_PRIVILEGES UNION SELECT TABLE_SCHEMA , TABLE_NAME , GRANTEE , PRIVILEGE_TYPE FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES ) privs ON (t.TABLE_SCHEMA = privs.TABLE_SCHEMA OR privs.TABLE_SCHEMA IS NULL) AND (t.TABLE_NAME = privs.TABLE_NAME OR privs.TABLE_NAME IS NULL) AND (privs.PRIVILEGE_TYPE <> 'USAGE') WHERE t.TABLE_SCHEMA NOT IN ( 'mysql' , 'information_schema' , 'performance_schema' ) GROUP BY t.TABLE_SCHEMA , t.TABLE_NAME , privs.GRANTEE ; {code} |
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: {code:sql} SELECT t.TABLE_SCHEMA , t.TABLE_NAME , privs.GRANTEE , GROUP_CONCAT(privs.PRIVILEGE_TYPE) AS PRIVILEGES FROM INFORMATION_SCHEMA.TABLES AS t JOIN ( SELECT NULL AS TABLE_SCHEMA , NULL AS TABLE_NAME , GRANTEE, PRIVILEGE_TYPE FROM INFORMATION_SCHEMA.USER_PRIVILEGES UNION SELECT TABLE_SCHEMA , NULL AS TABLE_NAME , GRANTEE , PRIVILEGE_TYPE FROM INFORMATION_SCHEMA.SCHEMA_PRIVILEGES UNION SELECT TABLE_SCHEMA , TABLE_NAME , GRANTEE , PRIVILEGE_TYPE FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES ) privs ON (t.TABLE_SCHEMA = privs.TABLE_SCHEMA OR privs.TABLE_SCHEMA IS NULL) AND (t.TABLE_NAME = privs.TABLE_NAME OR privs.TABLE_NAME IS NULL) AND (privs.PRIVILEGE_TYPE <> 'USAGE') WHERE t.TABLE_SCHEMA NOT IN ( 'mysql' , 'information_schema' , 'performance_schema' ) GROUP BY t.TABLE_SCHEMA , t.TABLE_NAME , privs.GRANTEE ; {code} |
Assignee | Ralf Gebhardt [ ralf.gebhardt@mariadb.com ] | Sergei Golubchik [ serg ] |
Priority | Minor [ 4 ] | Critical [ 2 ] |
Fix Version/s | 11.4 [ 29301 ] |
Assignee | Sergei Golubchik [ serg ] | Oleg Smirnov [ JIRAUSER50405 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Attachment | MDEV-24486.sql [ 72485 ] |
Assignee | Oleg Smirnov [ JIRAUSER50405 ] | Sergei Golubchik [ serg ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Sergei Golubchik [ serg ] | Oleg Smirnov [ JIRAUSER50405 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Testing [ 10301 ] |
Assignee | Oleg Smirnov [ JIRAUSER50405 ] | Elena Stepanova [ elenst ] |
Assignee | Elena Stepanova [ elenst ] | Alice Sherepa [ alice ] |
Issue Type | Task [ 3 ] | New Feature [ 2 ] |
Assignee | Alice Sherepa [ alice ] | Oleg Smirnov [ JIRAUSER50405 ] |
Status | In Testing [ 10301 ] | Stalled [ 10000 ] |
Link | This issue relates to MDEV-32941 [ MDEV-32941 ] |
Link | This issue blocks MENT-2007 [ MENT-2007 ] |
Component/s | Information Schema [ 14413 ] | |
Fix Version/s | 11.4.1 [ 29523 ] | |
Fix Version/s | 11.4 [ 29301 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Resolution | Fixed [ 1 ] | |
Status | Closed [ 6 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Priority | Critical [ 2 ] | Blocker [ 1 ] |
Assignee | Oleg Smirnov [ JIRAUSER50405 ] | Sergei Golubchik [ serg ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Sergei Golubchik [ serg ] | Oleg Smirnov [ JIRAUSER50405 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link | This issue causes TODO-4495 [ TODO-4495 ] |
Link | This issue causes TODO-4495 [ TODO-4495 ] |
Link | This issue is part of TODO-4495 [ TODO-4495 ] |
Labels | Preview_11.4 |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 36728 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 36728 ] |
Zendesk Related Tickets | 102362 |
Link | This issue causes MDEV-36030 [ MDEV-36030 ] |
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.