MDEV-24486 Add table_privileges view to the sys schema

The existing INFORMATION_SCHEMA.TABLE_PRIVILEGES displays only those
privileges that were specifically granted on the table level,
whereas it may be useful to see privileges granted at the database
and global level.

This commit adds a new view `table_privileges` to the `sys` schema
for that purpose. The view shows privileges on existing tables
and views, combining all possible levels:
 - user_privileges
 - schema_privileges
 - table_privileges
This commit is contained in:
Oleg Smirnov
2023-11-16 16:54:16 +07:00
parent 6b2287fff2
commit 1a5e69b42b
30 changed files with 341 additions and 12 deletions

View File

@ -269,6 +269,11 @@ constexpr privilege_t PROC_DDL_ACLS=
constexpr privilege_t SHOW_PROC_WITHOUT_DEFINITION_ACLS=
PROC_DDL_ACLS | EXECUTE_ACL;
/*
When changing this, don't forget to update tables_priv
at scripts/mariadb_system_tables.sql, scripts/mariadb_system_tables_fix.sql
and scripts/sys_schema/i_s/table_privileges.sql
*/
constexpr privilege_t TABLE_ACLS=
COL_DML_ACLS | ALL_TABLE_DDL_ACLS | VIEW_ACLS |
GRANT_ACL | REFERENCES_ACL |