Debian Codegraph @

mysql-test/suite/perfschema/t/global_read_lock.test

raw
1 # Tests for PERFORMANCE_SCHEMA
2 #
3 # Test the effect of a flush tables with read lock on setup_ tables.
4
5 --source include/not_embedded.inc
6 --source include/have_perfschema.inc
7
8 use performance_schema;
9
10 # Make test robust against errors in other tests.
11 # Ensure that instrumentation is turned on when we create new connection.
12 update performance_schema.setup_instruments set enabled='YES';
13
14 create user pfsuser@localhost;
15 grant SELECT, UPDATE, LOCK TABLES on performance_schema.* to pfsuser@localhost;
16 flush privileges;
17
18 connect (con1, localhost, pfsuser, ,"*NO-ONE*");
19
20 lock tables performance_schema.setup_instruments read;
21 --disable_result_log
22 select * from performance_schema.setup_instruments;
23 --enable_result_log
24 unlock tables;
25
26 lock tables performance_schema.setup_instruments write;
27 update performance_schema.setup_instruments set enabled='NO';
28 update performance_schema.setup_instruments set enabled='YES';
29 unlock tables;
30
31 connection default;
32
33 flush tables with read lock;
34
35 connection con1;
36
37 lock tables performance_schema.setup_instruments read;
38 --disable_result_log
39 select * from performance_schema.setup_instruments;
40 --enable_result_log
41 unlock tables;
42
43 # This will block
44 --send
45 lock tables performance_schema.setup_instruments write;
46
47 connection default;
48
49 let $wait_condition= select 1 from performance_schema.events_waits_current where event_name like "wait/synch/cond/sql/MDL_context::COND_wait_status";
50
51 --source include/wait_condition.inc
52
53 # Observe the blocked thread in the performance schema :)
54 select event_name,
55 left(source, locate(":", source)) as short_source,
56 if(timer_end IS NULL, NULL, "SET") as timer_end,
57 if(timer_wait IS NULL, NULL, "SET") as timer_wait,
58 operation
59 from performance_schema.events_waits_current
60 where event_name like "wait/synch/cond/sql/MDL_context::COND_wait_status";
61
62 unlock tables;
63
64 connection con1;
65 --reap
66
67 update performance_schema.setup_instruments set enabled='NO';
68 update performance_schema.setup_instruments set enabled='YES';
69 unlock tables;
70
71 disconnect con1;
72 --source include/wait_until_disconnected.inc
73
74 connection default;
75
76 drop user pfsuser@localhost;
77 flush privileges;
78