Type:
New Feature
Priority:
Blocker
Resolution:
Fixed
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
;
Sergei Golubchik
made changes -
2021-12-06 21:21
Workflow
MariaDB v3
[ 117352
]
MariaDB v4
[ 131427
]
AirFocus
made changes -
2022-08-09 16:10
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}
Sergei Golubchik
made changes -
2023-11-02 08:58
Priority
Minor
[ 4
]
Critical
[ 2
]
Sergei Golubchik
made changes -
2023-11-02 08:58
Assignee
Sergei Golubchik
[ serg
]
Oleg Smirnov
[ JIRAUSER50405
]
Oleg Smirnov
made changes -
2023-11-08 07:21
Status
Open
[ 1
]
In Progress
[ 3
]
Oleg Smirnov
made changes -
2023-11-20 14:24
Assignee
Oleg Smirnov
[ JIRAUSER50405
]
Sergei Golubchik
[ serg
]
Status
In Progress
[ 3
]
In Review
[ 10002
]
Sergei Golubchik
made changes -
2023-11-20 22:50
Assignee
Sergei Golubchik
[ serg
]
Oleg Smirnov
[ JIRAUSER50405
]
Status
In Review
[ 10002
]
Stalled
[ 10000
]
Oleg Smirnov
made changes -
2023-11-21 10:13
Status
Stalled
[ 10000
]
In Testing
[ 10301
]
Oleg Smirnov
made changes -
2023-11-21 12:19
Assignee
Oleg Smirnov
[ JIRAUSER50405
]
Elena Stepanova
[ elenst
]
Alice Sherepa
made changes -
2023-11-27 09:55
Assignee
Elena Stepanova
[ elenst
]
Alice Sherepa
[ alice
]
Julien Fritsch
made changes -
2023-11-30 16:30
Issue Type
Task
[ 3
]
New Feature
[ 2
]
Alice Sherepa
made changes -
2023-12-01 16:50
Assignee
Alice Sherepa
[ alice
]
Oleg Smirnov
[ JIRAUSER50405
]
Alice Sherepa
made changes -
2023-12-01 16:50
Status
In Testing
[ 10301
]
Stalled
[ 10000
]
Ralf Gebhardt
made changes -
2023-12-05 07:47
Link
This issue blocks MENT-2007
[ MENT-2007
]
Oleg Smirnov
made changes -
2023-12-05 09:39
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
]
Oleg Smirnov
made changes -
2023-12-07 10:26
Resolution
Fixed
[ 1
]
Status
Closed
[ 6
]
Stalled
[ 10000
]
Oleg Smirnov
made changes -
2023-12-07 10:26
Status
Stalled
[ 10000
]
In Progress
[ 3
]
Ralf Gebhardt
made changes -
2023-12-07 13:07
Priority
Critical
[ 2
]
Blocker
[ 1
]
Oleg Smirnov
made changes -
2023-12-08 08:16
Assignee
Oleg Smirnov
[ JIRAUSER50405
]
Sergei Golubchik
[ serg
]
Status
In Progress
[ 3
]
In Review
[ 10002
]
Sergei Golubchik
made changes -
2023-12-08 10:21
Assignee
Sergei Golubchik
[ serg
]
Oleg Smirnov
[ JIRAUSER50405
]
Status
In Review
[ 10002
]
Stalled
[ 10000
]
Oleg Smirnov
made changes -
2023-12-08 17:06
Resolution
Fixed
[ 1
]
Status
Stalled
[ 10000
]
Closed
[ 6
]
Sergei Golubchik
made changes -
2023-12-22 09:35
Link
This issue causes TODO-4495
[ TODO-4495
]
Sergei Golubchik
made changes -
2023-12-22 11:12
Link
This issue causes TODO-4495
[ TODO-4495
]
Sergei Golubchik
made changes -
2023-12-22 11:13
Link
This issue is part of TODO-4495
[ TODO-4495
]
Rob Schwyzer (Inactive)
made changes -
2024-04-04 20:02
Remote Link
This issue links to "Page (MariaDB Confluence)"
[ 36728
]
Rob Schwyzer (Inactive)
made changes -
2024-04-05 18:33
Remote Link
This issue links to "Page (MariaDB Confluence)"
[ 36728
]
{"report":{"fcp":1498.7999999523163,"ttfb":705.1999998092651,"pageVisibility":"visible","entityId":95449,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"0f6c0b1e-50e9-41d1-a8ea-29755aa98102","navigationType":0,"readyForUser":1589.5999999046326,"redirectCount":0,"resourceLoadedEnd":2145.5999999046326,"resourceLoadedStart":728.5,"resourceTiming":[{"duration":237.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":728.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":728.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":965.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":237.10000014305115,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":728.8999998569489,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":728.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":966,"responseStart":0,"secureConnectionStart":0},{"duration":246.79999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":729,"connectEnd":729,"connectStart":729,"domainLookupEnd":729,"domainLookupStart":729,"fetchStart":729,"redirectEnd":0,"redirectStart":0,"requestStart":729,"responseEnd":975.7999999523163,"responseStart":975.7999999523163,"secureConnectionStart":729},{"duration":439.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":729.1999998092651,"connectEnd":729.1999998092651,"connectStart":729.1999998092651,"domainLookupEnd":729.1999998092651,"domainLookupStart":729.1999998092651,"fetchStart":729.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":729.1999998092651,"responseEnd":1169.0999999046326,"responseStart":1169.0999999046326,"secureConnectionStart":729.1999998092651},{"duration":443.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":729.5,"connectEnd":729.5,"connectStart":729.5,"domainLookupEnd":729.5,"domainLookupStart":729.5,"fetchStart":729.5,"redirectEnd":0,"redirectStart":0,"requestStart":729.5,"responseEnd":1173.0999999046326,"responseStart":1173.0999999046326,"secureConnectionStart":729.5},{"duration":444.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":729.5999999046326,"connectEnd":729.5999999046326,"connectStart":729.5999999046326,"domainLookupEnd":729.5999999046326,"domainLookupStart":729.5999999046326,"fetchStart":729.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":729.5999999046326,"responseEnd":1173.6999998092651,"responseStart":1173.6999998092651,"secureConnectionStart":729.5999999046326},{"duration":444.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":729.8999998569489,"connectEnd":729.8999998569489,"connectStart":729.8999998569489,"domainLookupEnd":729.8999998569489,"domainLookupStart":729.8999998569489,"fetchStart":729.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":729.8999998569489,"responseEnd":1174.1999998092651,"responseStart":1174.1999998092651,"secureConnectionStart":729.8999998569489},{"duration":445,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":730,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":730,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1175,"responseStart":0,"secureConnectionStart":0},{"duration":444.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":730.1999998092651,"connectEnd":730.1999998092651,"connectStart":730.1999998092651,"domainLookupEnd":730.1999998092651,"domainLookupStart":730.1999998092651,"fetchStart":730.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":730.1999998092651,"responseEnd":1174.7999999523163,"responseStart":1174.7999999523163,"secureConnectionStart":730.1999998092651},{"duration":445.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":730.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":730.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1175.3999998569489,"responseStart":0,"secureConnectionStart":0},{"duration":445.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":730.5,"connectEnd":730.5,"connectStart":730.5,"domainLookupEnd":730.5,"domainLookupStart":730.5,"fetchStart":730.5,"redirectEnd":0,"redirectStart":0,"requestStart":730.5,"responseEnd":1175.5999999046326,"responseStart":1175.5999999046326,"secureConnectionStart":730.5},{"duration":799.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":731.5999999046326,"connectEnd":731.5999999046326,"connectStart":731.5999999046326,"domainLookupEnd":731.5999999046326,"domainLookupStart":731.5999999046326,"fetchStart":731.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":731.5999999046326,"responseEnd":1531.2999999523163,"responseStart":1531.2999999523163,"secureConnectionStart":731.5999999046326},{"duration":1399.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":731.6999998092651,"connectEnd":731.6999998092651,"connectStart":731.6999998092651,"domainLookupEnd":731.6999998092651,"domainLookupStart":731.6999998092651,"fetchStart":731.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":731.6999998092651,"responseEnd":2131.5,"responseStart":2131.5,"secureConnectionStart":731.6999998092651},{"duration":232.09999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1130.7999999523163,"connectEnd":1130.7999999523163,"connectStart":1130.7999999523163,"domainLookupEnd":1130.7999999523163,"domainLookupStart":1130.7999999523163,"fetchStart":1130.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1130.7999999523163,"responseEnd":1362.8999998569489,"responseStart":1362.8999998569489,"secureConnectionStart":1130.7999999523163},{"duration":680.6999998092651,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1450,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1450,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2130.699999809265,"responseStart":0,"secureConnectionStart":0},{"duration":685.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1450.8999998569489,"connectEnd":1450.8999998569489,"connectStart":1450.8999998569489,"domainLookupEnd":1450.8999998569489,"domainLookupStart":1450.8999998569489,"fetchStart":1450.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":1450.8999998569489,"responseEnd":2136.199999809265,"responseStart":2136.199999809265,"secureConnectionStart":1450.8999998569489},{"duration":694.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1451.2999999523163,"connectEnd":1451.2999999523163,"connectStart":1451.2999999523163,"domainLookupEnd":1451.2999999523163,"domainLookupStart":1451.2999999523163,"fetchStart":1451.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":1451.2999999523163,"responseEnd":2145.5999999046326,"responseStart":2145.5999999046326,"secureConnectionStart":1451.2999999523163},{"duration":689.9000000953674,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1492.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1492.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2182,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":442,"responseStart":705,"responseEnd":716,"domLoading":725,"domInteractive":2184,"domContentLoadedEventStart":2184,"domContentLoadedEventEnd":2243,"domComplete":2854,"loadEventStart":2854,"loadEventEnd":2854,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2138.399999856949},{"name":"bigPipe.sidebar-id.end","time":2139.199999809265},{"name":"bigPipe.activity-panel-pipe-id.start","time":2139.399999856949},{"name":"bigPipe.activity-panel-pipe-id.end","time":2146.899999856949},{"name":"activityTabFullyLoaded","time":2274.699999809265}],"measures":[],"correlationId":"158bccecec54ed","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":198,"dbReadsTimeInMs":45,"dbConnsTimeInMs":57,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}