##
## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
##
## Verify handling of the SELECT and PROCESS privileges.
##
## Test cases:
## - Execute SHOW PROCESSLIST (new and legacy) with all privileges
## - Execute SELECT on the performance_schema.processlist and information_schema.processlist with all privileges
## - Execute SHOW PROCESSLIST (new and legacy) with no privileges
## - Execute SELECT on the performance_schema.processlist and information_schema.processlist with no privileges
##
## Results must be manually verified.
### Setup ###
select @@global.performance_schema_show_processlist into @save_processlist;
# Control users
create user user_00@localhost, user_01@localhost;
grant ALL on *.* to user_00@localhost;
grant ALL on *.* to user_01@localhost;
# Test users
create user user_all@localhost, user_none@localhost;
grant ALL on *.* to user_all@localhost;
grant USAGE on *.* to user_none@localhost;
flush privileges;
show grants for user_all@localhost;
Grants for user_all@localhost
GRANT ALL PRIVILEGES ON *.* TO 'user_all'@'localhost'
show grants for user_none@localhost;
Grants for user_none@localhost
GRANT USAGE ON *.* TO 'user_none'@'localhost'
# Wait for queries to appear in the processlist table
### Execute SHOW PROCESSLIST with all privileges
### Expect all users
# New SHOW PROCESSLIST set @@global.performance_schema_show_processlist = on;
SHOW FULL PROCESSLIST;
Id User Host db Command Time State Info
<Id> event_scheduler <Host> NULL <Command> <Time> <State> NULL
<Id> root <Host> test <Command> <Time> <State> NULL
<Id> user_00 <Host> test <Command> <Time> <State> NULL
<Id> user_01 <Host> test <Command> <Time> <State> NULL
<Id> user_all <Host> test Query <Time> <State> SHOW FULL PROCESSLIST
<Id> user_all <Host> test Query <Time> <State> insert into test.t1 values (0, 0, 0, 0)
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Performance Schema processlist table
select * from performance_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> event_scheduler <Host> NULL <Command> <Time> <State> NULL
<Id> root <Host> test <Command> <Time> <State> NULL
<Id> user_00 <Host> test <Command> <Time> <State> NULL
<Id> user_01 <Host> test <Command> <Time> <State> NULL
<Id> user_all <Host> test Query <Time> <State> select * from performance_schema.processlist order by user, id
<Id> user_all <Host> test Query <Time> <State> insert into test.t1 values (0, 0, 0, 0)
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Information Schema processlist table
select * from information_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> event_scheduler <Host> NULL <Command> <Time> <State> NULL
<Id> root <Host> test <Command> <Time> <State> NULL
<Id> user_00 <Host> test <Command> <Time> <State> NULL
<Id> user_01 <Host> test <Command> <Time> <State> NULL
<Id> user_all <Host> test Query <Time> <State> select * from information_schema.processlist order by user, id
<Id> user_all <Host> test Query <Time> <State> insert into test.t1 values (0, 0, 0, 0)
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Legacy SHOW PROCESSLIST set @@global.performance_schema_show_processlist = off;
SHOW FULL PROCESSLIST;
Id User Host db Command Time State Info
<Id> event_scheduler <Host> NULL <Command> <Time> <State> NULL
<Id> root <Host> test <Command> <Time> <State> NULL
<Id> user_00 <Host> test <Command> <Time> <State> NULL
<Id> user_01 <Host> test <Command> <Time> <State> NULL
<Id> user_all <Host> test Query <Time> <State> SHOW FULL PROCESSLIST
<Id> user_all <Host> test Query <Time> <State> insert into test.t1 values (0, 0, 0, 0)
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Performance Schema processlist table
select * from performance_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> event_scheduler <Host> NULL <Command> <Time> <State> NULL
<Id> root <Host> test <Command> <Time> <State> NULL
<Id> user_00 <Host> test <Command> <Time> <State> NULL
<Id> user_01 <Host> test <Command> <Time> <State> NULL
<Id> user_all <Host> test Query <Time> <State> select * from performance_schema.processlist order by user, id
<Id> user_all <Host> test Query <Time> <State> insert into test.t1 values (0, 0, 0, 0)
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Information Schema processlist table
select * from information_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> event_scheduler <Host> NULL <Command> <Time> <State> NULL
<Id> root <Host> test <Command> <Time> <State> NULL
<Id> user_00 <Host> test <Command> <Time> <State> NULL
<Id> user_01 <Host> test <Command> <Time> <State> NULL
<Id> user_all <Host> test Query <Time> <State> select * from information_schema.processlist order by user, id
<Id> user_all <Host> test Query <Time> <State> insert into test.t1 values (0, 0, 0, 0)
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
### Execute SHOW PROCESSLIST with no SELECT and no PROCESS privileges
### Expect processes only from user_none
# New SHOW PROCESSLIST set @@global.performance_schema_show_processlist = on;
# Connection con_none_1
SHOW FULL PROCESSLIST;
Id User Host db Command Time State Info
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> SHOW FULL PROCESSLIST
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Performance Schema processlist table
select * from performance_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> user_none <Host> test Query <Time> <State> select * from performance_schema.processlist order by user, id
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Information Schema processlist table
select * from information_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> user_none <Host> test Query <Time> <State> select * from information_schema.processlist order by user, id
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Confirm that only processes from user_none are visible
select count(*) as "Expect 0" from performance_schema.processlist
where user not in ('user_none');
Expect 0 0
# Legacy SHOW PROCESSLIST set @@global.performance_schema_show_processlist = off;
# Connection con_none_1
SHOW FULL PROCESSLIST;
Id User Host db Command Time State Info
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> SHOW FULL PROCESSLIST
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Performance Schema processlist table
select * from performance_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> user_none <Host> test Query <Time> <State> select * from performance_schema.processlist order by user, id
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
# Information Schema processlist table
select * from information_schema.processlist order by user, id;
ID USER HOST DB COMMAND TIME STATE INFO
<Id> user_none <Host> test Query <Time> <State> select * from information_schema.processlist order by user, id
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test <Command> <Time> <State> NULL
<Id> user_none <Host> test Query <Time> <State> update test.t1 set s1 = s1 + 1, s2 = s2 + 2
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.