Debian Codegraph @

mysql-test/suite/perfschema/t/column_privilege.test

raw
1 # Tests for PERFORMANCE_SCHEMA
2 # Test how columns privileges can be used on performance schema tables,
3 # for very fine control.
4
5 show grants;
6
7 create user 'pfs_user_5'@localhost;
8 grant usage on *.* to 'pfs_user_5'@localhost with GRANT OPTION;
9
10 # Test per column privileges on performance_schema
11
12 grant SELECT(thread_id, event_id) on performance_schema.events_waits_current
13 to 'pfs_user_5'@localhost;
14
15 grant UPDATE(enabled) on performance_schema.setup_instruments
16 to 'pfs_user_5'@localhost;
17
18 flush privileges;
19
20 connect (con1, localhost, pfs_user_5, , );
21
22 # Commented because the result is not consistent (uppercase/lowercase)
23 # show grants;
24
25 # For statements that works, we do not look at the output
26 --disable_result_log
27
28 select thread_id from performance_schema.events_waits_current;
29
30 select thread_id, event_id from performance_schema.events_waits_current;
31
32 update performance_schema.setup_instruments set enabled='YES';
33
34 --enable_result_log
35
36 # For statements that are denied, check the error number and error text.
37
38 --error ER_COLUMNACCESS_DENIED_ERROR
39 select event_name from performance_schema.events_waits_current;
40
41 --error ER_COLUMNACCESS_DENIED_ERROR
42 select thread_id, event_id, event_name
43 from performance_schema.events_waits_current;
44
45 --error ER_COLUMNACCESS_DENIED_ERROR
46 update performance_schema.setup_instruments set name='illegal';
47
48 --error ER_COLUMNACCESS_DENIED_ERROR
49 update performance_schema.setup_instruments set timed='NO';
50
51 # Cleanup
52
53 --connection default
54 --disconnect con1
55 REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'pfs_user_5'@localhost;
56 DROP USER 'pfs_user_5'@localhost;
57 flush privileges;
58 UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
59