summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/perfschema/t/processlist.test
blob: fed22153931ab16f3c2a74f243cc13d3a4708e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
--echo ##
--echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
--echo ##
--echo ## Test cases:
--echo ##   1. Execute the new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
--echo ##   2. Execute the legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
--echo ##   3. Verify that performance_schema_show_processlist = ON executes the new implementation
--echo ##   4. Verify that performance_schema_show_processlist = OFF executes the legacy code path
--echo ##
--echo ## Results must be manually verified.

--source include/no_protocol.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc

--echo
--echo ### Setup ###
--echo
select @@global.performance_schema_show_processlist into @save_processlist;

--echo
create user user1@localhost, user2@localhost,
            user3@localhost, user4@localhost;
--echo
grant ALL on *.* to user1@localhost;
grant ALL on *.* to user2@localhost;
grant ALL on *.* to user3@localhost;
grant ALL on *.* to user4@localhost;
--echo
flush privileges;

--echo
use test;
create table test.t1 (s1 int, s2 int, s3 int, s4 int);

--echo
--echo # Switch to (con0, localhost, root, , )
connect (con0, localhost, root, , );
--echo
insert into test.t1 values(1, 1, 1, 1);
insert into test.t1 values(2, 2, 2, 2);
insert into test.t1 values(3, 3, 3, 3);
insert into test.t1 values(4, 4, 4, 4);

--echo
--echo # Lock test.t1, insert/update/deletes will block
lock tables t1 read;

--echo
--echo # Connect (con1, localhost, user1, , )
connect (con1, localhost, user1, , );
--send insert into test.t1 values (0, 0, 0, 0)

--echo
--echo # Connect (con2, localhost, user2, , )
connect (con2, localhost, user2, , );
# Create a query > 100 characters
--send update test.t1 set s1 = s1 + 1, s2 = s2 + 2, s3 = s3 + 3, s4 = ((s4 + 4) * (s4 + 5)) + 12345 + 67890 + 11111 + 22222 + 33333 + 44444 + 55555 + 99999;
--echo
--echo # Connect (con3, localhost, user3, , )
connect (con3, localhost, user3, , );
--send delete from test.t1 where s1 = 3

--echo
--echo # Connect (con4, localhost, user4, , )
connect (con4, localhost, user4, , );
--send insert into test.t1 values (4, 4, 4, 4)

--echo
--echo # Connection default
--connection default

--echo
--echo # Wait for queries to appear in the processlist table
let $wait_condition = select count(*) >= 4 from information_schema.processlist
                      where state like '%metadata%';
--source include/wait_condition.inc

--echo
--echo
--echo ### Execute new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
--echo
let $pfs_spl = on;
--source ../include/processlist_set.inc
--source ../include/processlist_load.inc

--echo
--echo
--echo ### Execute legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
--echo
let $pfs_spl = off;
--source ../include/processlist_set.inc
--source ../include/processlist_load.inc

--echo
--echo
--echo ### Verify feature code path
--echo
--echo # Enable SHOW PROCESSLIST via the Performance Schema
let $pfs_spl = on;
--source ../include/processlist_set.inc

--echo
--echo # Connection default, send SHOW PROCESSLIST
--connection default
SET DEBUG_SYNC='pfs_show_processlist_performance_schema SIGNAL pfs_processlist_pfs WAIT_FOR continue';
--send SHOW FULL PROCESSLIST

--echo
--echo # Connection con0
--connection con0
SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_pfs';
SET DEBUG_SYNC='now SIGNAL continue';

--echo
--echo # Connection default, reap
--connection default
--replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
--sorted_result
--reap

--echo
--echo
--echo ### Verify legacy code path
--echo
--echo # Enable the legacy SHOW PROCESSLIST
let $pfs_spl = off;
--source ../include/processlist_set.inc

--echo
--echo # Connection default, send SHOW PROCESSLIST
--connection default
SET DEBUG_SYNC='RESET';
SET DEBUG_SYNC='pfs_show_processlist_legacy SIGNAL pfs_processlist_legacy WAIT_FOR continue';
--send SHOW FULL PROCESSLIST

--echo
--echo # Connection con0
--connection con0
SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_legacy';
SET DEBUG_SYNC='now SIGNAL continue';

--echo
--echo # Connection default, reap
--connection default
--replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
--sorted_result
--reap

--echo
--echo
--echo ### Clean up ###
--echo

--echo # Connection con0, unlock test.t1, disconnect
--connection con0
unlock tables;
--disconnect con0

--disable_query_log
--disable_result_log
--echo
--echo # Connection con1, reap, disconnect
--connection con1
--reap
--disconnect con1

--echo # Connection con2, reap, disconnect
--connection con2
--reap
--disconnect con2

--echo # Connection con3, reap, disconnect
--connection con3
--reap
--disconnect con3

--echo # Connection con4, reap, disconnect
--connection con4
--reap
--disconnect con4
--enable_result_log
--enable_query_log

--echo
--echo # Connection default
--connection default

--echo
drop table test.t1;
drop user user1@localhost;
drop user user2@localhost;
drop user user3@localhost;
drop user user4@localhost;
--echo
set @@global.performance_schema_show_processlist = @save_processlist;