Skip to content

Commit

Permalink
MDEV-24486 Add table_privileges view to the sys schema
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mariadb-OlegSmirnov committed Dec 5, 2023
1 parent 6b2287f commit 1a5e69b
Show file tree
Hide file tree
Showing 30 changed files with 341 additions and 12 deletions.
2 changes: 2 additions & 0 deletions mysql-test/main/ctype_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -464,6 +465,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/main/information_schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ TABLES TABLES
TABLESPACES TABLESPACES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_PRIVILEGES table_privileges
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
t1 t1
Expand All @@ -163,6 +164,7 @@ TABLES TABLES
TABLESPACES TABLESPACES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_PRIVILEGES table_privileges
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
t1 t1
Expand All @@ -186,6 +188,7 @@ TABLES TABLES
TABLESPACES TABLESPACES
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_PRIVILEGES table_privileges
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
t1 t1
Expand Down Expand Up @@ -1508,6 +1511,7 @@ statements_with_runtimes_in_95th_percentile YES
statements_with_sorting YES
statements_with_temp_tables YES
statement_analysis YES
table_privileges NO
user YES
user_summary NO
user_summary_by_file_io NO
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/log_tables_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/lowercase_fs_off.result
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_json_mysql_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_upgrade-20228.result
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/main/mysql_upgrade-28915.result
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -413,6 +414,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_upgrade-6984.result
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/main/mysql_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -229,6 +230,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -381,6 +383,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -539,6 +542,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -697,6 +701,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -858,6 +863,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -1059,6 +1065,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -1231,6 +1238,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -1411,6 +1419,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -1633,6 +1642,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -1813,6 +1823,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -2045,6 +2056,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -2265,6 +2277,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_upgrade_mysql_json_datatype.result
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_upgrade_ssl.result
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/main/mysql_upgrade_view.result
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -409,6 +410,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -637,6 +639,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/upgrade_MDEV-19650.result
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/main/upgrade_MDEV-23102-1.result
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -399,6 +400,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/main/upgrade_MDEV-23102-2.result
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down Expand Up @@ -375,6 +376,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/upgrade_mdev_24363.result
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ sys.statements_with_full_table_scans OK
sys.statements_with_runtimes_in_95th_percentile OK
sys.statements_with_sorting OK
sys.statements_with_temp_tables OK
sys.table_privileges OK
sys.user_summary OK
sys.user_summary_by_file_io OK
sys.user_summary_by_file_io_type OK
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/sysschema/r/all_sys_objects_exist.result
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ statements_with_sorting
statements_with_temp_tables
statement_analysis
sys_config
table_privileges
user_summary
user_summary_by_file_io
user_summary_by_file_io_type
Expand Down Expand Up @@ -159,4 +160,4 @@ SELECT TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA = 'sys
TRIGGER_NAME
SELECT sys_version FROM sys.version;
sys_version
1.5.1
1.5.2

0 comments on commit 1a5e69b

Please sign in to comment.