drop procedure if exists check_instrument;
truncate table performance_schema.events_statements_summary_by_digest;
flush status;
create procedure check_instrument(in instr_name varchar(128))
begin
declare count_expected integer;
declare count_actual integer;
declare is_wait integer;
declare is_stage integer;
declare is_statement integer;
declare is_wait_table integer;
declare is_stage_table integer;
declare is_statement_table integer;
declare pfs_table_name varchar(64);
declare msg varchar(512);
declare msg_detail varchar(512);
declare cmd_1 varchar(512);
declare cmd_2 varchar(512);
declare done integer default 0;
declare debug integer default 0;
declare pfs_cursor CURSOR FOR
select table_name from information_schema.tables
where table_schema= 'performance_schema'
      and table_name like "events_%_by_event_name%";
declare continue handler for sqlstate '02000'
    set done = 1;
select (instr_name like "wait/%") or (instr_name like "idle/%") into is_wait;
select (instr_name like "stage/%") into is_stage;
select (instr_name like "statement/%") into is_statement;
select instr_name, is_wait, is_stage, is_statement;
select count(name)
from performance_schema.setup_instruments
where (name like (concat(instr_name, "%")))
and (not name like "%/abstract/%")
into count_expected;
set cmd_1= "select count(*) from (select distinct event_name from performance_schema.";
set cmd_2= concat(" where event_name like \"",
                    instr_name,
                    "%\") t into @count_actual");
open pfs_cursor;
repeat
fetch pfs_cursor into pfs_table_name;
if not done then
select (pfs_table_name like "%waits%") into is_wait_table;
select (pfs_table_name like "%stages%") into is_stage_table;
select (pfs_table_name like "%statements%") into is_statement_table;
select concat("Checking table ", pfs_table_name, " ...") as status;
select concat(cmd_1, pfs_table_name, cmd_2) into @cmd;
if debug = 1
then
select @cmd;
end if;
prepare stmt from @cmd;
execute stmt;
drop prepare stmt;
set msg_detail= concat("table ", pfs_table_name,
", instruments ", count_expected,
", found ", @count_actual);
if is_wait = 1 and is_wait_table = 1 and @count_actual <> count_expected
then
set msg= concat("Missing wait events: ", msg_detail);
signal sqlstate '05000' set message_text= msg;
end if;
if is_wait = 1 and is_wait_table = 0 and @count_actual <> 0
then
set msg= concat("Unexpected wait events: ", msg_detail);
signal sqlstate '05000' set message_text= msg;
end if;
if is_stage = 1 and is_stage_table = 1 and @count_actual <> count_expected
then
set msg= concat("Missing stage events: ", msg_detail);
signal sqlstate '05000' set message_text= msg;
end if;
if is_stage = 1 and is_stage_table = 0 and @count_actual <> 0
then
set msg= concat("Unexpected stage events: ", msg_detail);
signal sqlstate '05000' set message_text= msg;
end if;
if is_statement = 1 and is_statement_table = 1 and @count_actual <> count_expected
then
set msg= concat("Missing statement events: ", msg_detail);
signal sqlstate '05000' set message_text= msg;
end if;
if is_statement = 1 and is_statement_table = 0 and @count_actual <> 0
then
set msg= concat("Unexpected statement events: ", msg_detail);
signal sqlstate '05000' set message_text= msg;
end if;
end if;
until done
end repeat;
close pfs_cursor;
-- Dont want to return a 02000 NOT FOUND, there should be a better way
signal sqlstate '01000' set message_text='Done', mysql_errno=12000;
end
$
show variables where
`Variable_name` != "performance_schema_max_statement_classes" and
`Variable_name` like "performance_schema%";
Variable_name	Value
performance_schema	ON
performance_schema_accounts_size	100
performance_schema_digests_size	200
performance_schema_events_stages_history_long_size	1000
performance_schema_events_stages_history_size	10
performance_schema_events_statements_history_long_size	1000
performance_schema_events_statements_history_size	10
performance_schema_events_waits_history_long_size	10000
performance_schema_events_waits_history_size	10
performance_schema_hosts_size	100
performance_schema_max_cond_classes	80
performance_schema_max_cond_instances	1000
performance_schema_max_digest_length	1024
performance_schema_max_file_classes	50
performance_schema_max_file_handles	32768
performance_schema_max_file_instances	10000
performance_schema_max_mutex_classes	200
performance_schema_max_mutex_instances	5000
performance_schema_max_rwlock_classes	40
performance_schema_max_rwlock_instances	5000
performance_schema_max_socket_classes	10
performance_schema_max_socket_instances	1000
performance_schema_max_stage_classes	150
performance_schema_max_table_handles	1000
performance_schema_max_table_instances	500
performance_schema_max_thread_classes	50
performance_schema_max_thread_instances	200
performance_schema_session_connect_attrs_size	2048
performance_schema_setup_actors_size	100
performance_schema_setup_objects_size	100
performance_schema_users_size	100
call check_instrument("wait/synch/mutex/");
instr_name	is_wait	is_stage	is_statement
wait/synch/mutex/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/synch/rwlock/");
instr_name	is_wait	is_stage	is_statement
wait/synch/rwlock/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/synch/cond/");
instr_name	is_wait	is_stage	is_statement
wait/synch/cond/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/synch/");
instr_name	is_wait	is_stage	is_statement
wait/synch/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/io/file/");
instr_name	is_wait	is_stage	is_statement
wait/io/file/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/io/net/");
instr_name	is_wait	is_stage	is_statement
wait/io/net/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/io/table/");
instr_name	is_wait	is_stage	is_statement
wait/io/table/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/io/");
instr_name	is_wait	is_stage	is_statement
wait/io/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/lock/table/");
instr_name	is_wait	is_stage	is_statement
wait/lock/table/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/lock/");
instr_name	is_wait	is_stage	is_statement
wait/lock/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("wait/");
instr_name	is_wait	is_stage	is_statement
wait/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("stage/");
instr_name	is_wait	is_stage	is_statement
stage/	0	1	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("statement/com/");
instr_name	is_wait	is_stage	is_statement
statement/com/	0	0	1
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("statement/sql/");
instr_name	is_wait	is_stage	is_statement
statement/sql/	0	0	1
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("statement/abstract/");
instr_name	is_wait	is_stage	is_statement
statement/abstract/	0	0	1
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("statement/");
instr_name	is_wait	is_stage	is_statement
statement/	0	0	1
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("idle/io/socket");
instr_name	is_wait	is_stage	is_statement
idle/io/socket	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
call check_instrument("idle/");
instr_name	is_wait	is_stage	is_statement
idle/	1	0	0
status
Checking table events_stages_summary_by_account_by_event_name ...
status
Checking table events_stages_summary_by_host_by_event_name ...
status
Checking table events_stages_summary_by_thread_by_event_name ...
status
Checking table events_stages_summary_by_user_by_event_name ...
status
Checking table events_stages_summary_global_by_event_name ...
status
Checking table events_statements_summary_by_account_by_event_name ...
status
Checking table events_statements_summary_by_host_by_event_name ...
status
Checking table events_statements_summary_by_thread_by_event_name ...
status
Checking table events_statements_summary_by_user_by_event_name ...
status
Checking table events_statements_summary_global_by_event_name ...
status
Checking table events_waits_summary_by_account_by_event_name ...
status
Checking table events_waits_summary_by_host_by_event_name ...
status
Checking table events_waits_summary_by_thread_by_event_name ...
status
Checking table events_waits_summary_by_user_by_event_name ...
status
Checking table events_waits_summary_global_by_event_name ...
Warnings:
Warning	12000	Done
drop procedure check_instrument;
