| 1 |
select * from performance_schema.setup_actors; |
| 2 |
HOST USER ROLE ENABLED HISTORY |
| 3 |
% % % YES YES |
| 4 |
truncate table performance_schema.setup_actors; |
| 5 |
insert into performance_schema.setup_actors |
| 6 |
values ('hosta', 'user1', '%', 'YES', 'YES'); |
| 7 |
insert into performance_schema.setup_actors |
| 8 |
values ('%', 'user2', '%', 'YES', 'YES'); |
| 9 |
insert into performance_schema.setup_actors |
| 10 |
values ('localhost', 'user3', '%', 'YES', 'YES'); |
| 11 |
insert into performance_schema.setup_actors |
| 12 |
values ('hostb', '%', '%', 'YES', 'YES'); |
| 13 |
select * from performance_schema.setup_actors |
| 14 |
order by USER, HOST, `ROLE`; |
| 15 |
HOST USER ROLE ENABLED HISTORY |
| 16 |
hostb % % YES YES |
| 17 |
hosta user1 % YES YES |
| 18 |
% user2 % YES YES |
| 19 |
localhost user3 % YES YES |
| 20 |
create user user1@localhost, user2@localhost, |
| 21 |
user3@localhost, user4@localhost, |
| 22 |
user5@localhost; |
| 23 |
grant ALL on *.* to user1@localhost; |
| 24 |
grant ALL on *.* to user2@localhost; |
| 25 |
grant ALL on *.* to user3@localhost; |
| 26 |
grant ALL on *.* to user4@localhost; |
| 27 |
grant select on test.* to user5@localhost; |
| 28 |
flush privileges; |
| 29 |
# Switch to (con1, localhost, user1, , ) |
| 30 |
select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 31 |
from performance_schema.threads |
| 32 |
where PROCESSLIST_ID = connection_id(); |
| 33 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 34 |
thread/sql/one_connection FOREGROUND NO user1 localhost |
| 35 |
# Switch to connection default |
| 36 |
insert into performance_schema.setup_actors |
| 37 |
values ('%', 'user1', '%', 'YES', 'YES'); |
| 38 |
# Switch to connection con1 |
| 39 |
select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 40 |
from performance_schema.threads |
| 41 |
where PROCESSLIST_ID = connection_id(); |
| 42 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 43 |
thread/sql/one_connection FOREGROUND NO user1 localhost |
| 44 |
# Disconnect con1 |
| 45 |
# Switch to (con2, localhost, user2, , ) |
| 46 |
select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 47 |
from performance_schema.threads |
| 48 |
where PROCESSLIST_ID=connection_id(); |
| 49 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 50 |
thread/sql/one_connection FOREGROUND YES user2 localhost |
| 51 |
# Disconnect con2 |
| 52 |
# Switch to connection default |
| 53 |
drop table if exists test.t1; |
| 54 |
create table test.t1 (col1 bigint); |
| 55 |
lock table test.t1 write; |
| 56 |
# Switch to (con3, localhost, user3, , ) |
| 57 |
select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 58 |
from performance_schema.threads |
| 59 |
where PROCESSLIST_ID = connection_id(); |
| 60 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 61 |
thread/sql/one_connection FOREGROUND YES user3 localhost |
| 62 |
# Send a statement to the server, but do not wait till the result |
| 63 |
# comes back. We will pull this later. |
| 64 |
insert into test.t1 set col1 = 1; |
| 65 |
# Switch to (con4, localhost, user4, , ) |
| 66 |
# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'. |
| 67 |
select count(*) = 1 |
| 68 |
from performance_schema.threads T inner join information_schema.PROCESSLIST P |
| 69 |
on T.PROCESSLIST_ID = P.ID and T.PROCESSLIST_USER = P.USER and |
| 70 |
T.PROCESSLIST_HOST = P.HOST and T.PROCESSLIST_DB = P.DB and |
| 71 |
T.PROCESSLIST_COMMAND = P.COMMAND and T.PROCESSLIST_INFO = P.INFO |
| 72 |
where T.PROCESSLIST_USER = 'user3' and T.NAME = 'thread/sql/one_connection'; |
| 73 |
count(*) = 1 |
| 74 |
1 |
| 75 |
Warnings: |
| 76 |
Warning 1287 'INFORMATION_SCHEMA.PROCESSLIST' is deprecated and will be removed in a future release. Please use performance_schema.processlist instead |
| 77 |
# Switch to connection default |
| 78 |
unlock tables; |
| 79 |
# Switch to connection con3 and reap the result of the no more blocked insert |
| 80 |
# Switch to connection default |
| 81 |
drop table test.t1; |
| 82 |
# Disconnect con3 |
| 83 |
# Switch to connection con4 |
| 84 |
select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 85 |
from performance_schema.threads |
| 86 |
where PROCESSLIST_ID = connection_id(); |
| 87 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 88 |
thread/sql/one_connection FOREGROUND NO user4 localhost |
| 89 |
# Disconnect con4 |
| 90 |
# Switch to connection default |
| 91 |
insert into performance_schema.setup_actors |
| 92 |
values ('localhost', '%', '%', 'YES', 'YES'); |
| 93 |
select * from performance_schema.setup_actors |
| 94 |
order by USER, HOST, `ROLE`; |
| 95 |
HOST USER ROLE ENABLED HISTORY |
| 96 |
hostb % % YES YES |
| 97 |
localhost % % YES YES |
| 98 |
% user1 % YES YES |
| 99 |
hosta user1 % YES YES |
| 100 |
% user2 % YES YES |
| 101 |
localhost user3 % YES YES |
| 102 |
# Switch to (con4b, localhost, user4, , ) |
| 103 |
select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 104 |
from performance_schema.threads |
| 105 |
where PROCESSLIST_ID = connection_id(); |
| 106 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 107 |
thread/sql/one_connection FOREGROUND YES user4 localhost |
| 108 |
# Disconnect con4b |
| 109 |
# Switch to connection default |
| 110 |
insert into performance_schema.setup_actors |
| 111 |
values ('%', 'user5', '%', 'YES', 'YES'); |
| 112 |
create sql security definer view test.v1 as select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST |
| 113 |
from performance_schema.threads |
| 114 |
where PROCESSLIST_ID = connection_id(); |
| 115 |
# Switch to (con5, localhost, user5, , ) |
| 116 |
select * from performance_schema.threads; |
| 117 |
ERROR 42000: SELECT command denied to user 'user5'@'localhost' for table 'threads' |
| 118 |
select * from test.v1; |
| 119 |
NAME TYPE INSTRUMENTED PROCESSLIST_USER PROCESSLIST_HOST |
| 120 |
thread/sql/one_connection FOREGROUND YES user5 localhost |
| 121 |
# Disconnect con5 |
| 122 |
# Switch to connection default and cleanup |
| 123 |
drop view test.v1; |
| 124 |
revoke all privileges, grant option from user1@localhost; |
| 125 |
revoke all privileges, grant option from user2@localhost; |
| 126 |
revoke all privileges, grant option from user3@localhost; |
| 127 |
revoke all privileges, grant option from user4@localhost; |
| 128 |
revoke all privileges, grant option from user5@localhost; |
| 129 |
drop user user1@localhost; |
| 130 |
drop user user2@localhost; |
| 131 |
drop user user3@localhost; |
| 132 |
drop user user4@localhost; |
| 133 |
drop user user5@localhost; |
| 134 |
flush privileges; |
| 135 |
truncate table performance_schema.setup_actors; |
| 136 |
insert into performance_schema.setup_actors |
| 137 |
values ('%', '%', '%', 'YES', 'YES'); |
| 138 |
select * from performance_schema.setup_actors; |
| 139 |
HOST USER ROLE ENABLED HISTORY |
| 140 |
% % % YES YES |