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