1UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
2UPDATE performance_schema.setup_instruments SET enabled = 'YES'
3WHERE name LIKE 'wait/synch/mutex/%'
4   OR name LIKE 'wait/synch/rwlock/%';
5truncate table performance_schema.events_statements_summary_by_digest;
6flush status;
7select NAME from performance_schema.mutex_instances
8where NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex' GROUP BY NAME;
9NAME
10wait/synch/mutex/mysys/THR_LOCK::mutex
11select NAME from performance_schema.rwlock_instances
12where NAME = 'wait/synch/rwlock/sql/LOCK_grant';
13NAME
14wait/synch/rwlock/sql/LOCK_grant
15DROP TABLE IF EXISTS t1;
16CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value')
17ENGINE=MyISAM;
18INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
19TRUNCATE TABLE performance_schema.events_waits_history_long;
20TRUNCATE TABLE performance_schema.events_waits_history;
21TRUNCATE TABLE performance_schema.events_waits_current;
22SELECT * FROM t1 WHERE id = 1;
23id	b
241	initial value
25SET @before_count = (SELECT SUM(TIMER_WAIT)
26FROM performance_schema.events_waits_history_long
27WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
28SELECT * FROM t1;
29id	b
301	initial value
312	initial value
323	initial value
334	initial value
345	initial value
356	initial value
367	initial value
378	initial value
38SET @after_count = (SELECT SUM(TIMER_WAIT)
39FROM performance_schema.events_waits_history_long
40WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
41SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_timed;
42test_fm1_timed
43Success
44UPDATE performance_schema.setup_instruments SET enabled = 'NO'
45WHERE NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex';
46TRUNCATE TABLE performance_schema.events_waits_history_long;
47TRUNCATE TABLE performance_schema.events_waits_history;
48TRUNCATE TABLE performance_schema.events_waits_current;
49SELECT * FROM t1 WHERE id = 1;
50id	b
511	initial value
52SET @before_count = (SELECT SUM(TIMER_WAIT)
53FROM performance_schema.events_waits_history_long
54WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
55SELECT * FROM t1;
56id	b
571	initial value
582	initial value
593	initial value
604	initial value
615	initial value
626	initial value
637	initial value
648	initial value
65SET @after_count = (SELECT SUM(TIMER_WAIT)
66FROM performance_schema.events_waits_history_long
67WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
68SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_timed;
69test_fm2_timed
70Success
71TRUNCATE TABLE performance_schema.events_waits_history_long;
72TRUNCATE TABLE performance_schema.events_waits_history;
73TRUNCATE TABLE performance_schema.events_waits_current;
74show variables like "%not_found%";
75Variable_name	Value
76SET @before_count = (SELECT SUM(TIMER_WAIT)
77FROM performance_schema.events_waits_history_long
78WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'));
79show variables like "%not_found%";
80Variable_name	Value
81SET @after_count = (SELECT SUM(TIMER_WAIT)
82FROM performance_schema.events_waits_history_long
83WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'));
84SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_rw_timed;
85test_fm1_rw_timed
86Success
87UPDATE performance_schema.setup_instruments SET enabled = 'NO'
88WHERE NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash';
89TRUNCATE TABLE performance_schema.events_waits_history_long;
90TRUNCATE TABLE performance_schema.events_waits_history;
91TRUNCATE TABLE performance_schema.events_waits_current;
92show variables like "%not_found%";
93Variable_name	Value
94SET @before_count = (SELECT SUM(TIMER_WAIT)
95FROM performance_schema.events_waits_history_long
96WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'));
97show variables like "%not_found%";
98Variable_name	Value
99SET @after_count = (SELECT SUM(TIMER_WAIT)
100FROM performance_schema.events_waits_history_long
101WHERE (EVENT_NAME = 'LOCK_system_variables_hash'));
102SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_rw_timed;
103test_fm2_rw_timed
104Success
105UPDATE performance_schema.setup_instruments SET enabled = 'YES';
106DROP TABLE t1;
107UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
108show status like "performance_schema%";
109Variable_name	Value
110Performance_schema_accounts_lost	0
111Performance_schema_cond_classes_lost	0
112Performance_schema_cond_instances_lost	0
113Performance_schema_digest_lost	0
114Performance_schema_file_classes_lost	0
115Performance_schema_file_handles_lost	0
116Performance_schema_file_instances_lost	0
117Performance_schema_hosts_lost	0
118Performance_schema_locker_lost	0
119Performance_schema_mutex_classes_lost	0
120Performance_schema_mutex_instances_lost	0
121Performance_schema_rwlock_classes_lost	0
122Performance_schema_rwlock_instances_lost	0
123Performance_schema_session_connect_attrs_lost	0
124Performance_schema_socket_classes_lost	0
125Performance_schema_socket_instances_lost	0
126Performance_schema_stage_classes_lost	0
127Performance_schema_statement_classes_lost	0
128Performance_schema_table_handles_lost	0
129Performance_schema_table_instances_lost	0
130Performance_schema_thread_classes_lost	0
131Performance_schema_thread_instances_lost	0
132Performance_schema_users_lost	0
133