1# Check the impact of changes done in HISTORY column in
2# performance_schema.setup_actors.
3
4--source include/not_embedded.inc
5--source include/have_perfschema.inc
6--source include/no_protocol.inc
7
8# Presence of the query cache changes query stages,
9# causing noise in the test output
10--source include/have_query_cache_disabled.inc
11
12create user user1@localhost;
13create user user2@localhost;
14create user user3@localhost;
15create user user4@localhost;
16
17grant ALL on *.* to user1@localhost;
18grant ALL on *.* to user2@localhost;
19grant ALL on *.* to user3@localhost;
20grant ALL on *.* to user4@localhost;
21
22flush privileges;
23
24select * from performance_schema.setup_consumers;
25
26--echo # Switch to (con1, localhost, user1, , )
27connect (con1, localhost, user1, , );
28
29update performance_schema.threads
30  set INSTRUMENTED='YES', HISTORY='YES'
31  where PROCESSLIST_ID = connection_id();
32
33let $con1_thread_id= `select THREAD_ID from performance_schema.threads
34  where PROCESSLIST_ID = connection_id()`;
35
36--echo # Switch to (con2, localhost, user2, , )
37connect (con2, localhost, user2, , );
38
39update performance_schema.threads
40  set INSTRUMENTED='YES', HISTORY='NO'
41  where PROCESSLIST_ID = connection_id();
42
43let $con2_thread_id= `select THREAD_ID from performance_schema.threads
44  where PROCESSLIST_ID = connection_id()`;
45
46--echo # Switch to (con3, localhost, user3, , )
47connect (con3, localhost, user3, , );
48
49update performance_schema.threads
50  set INSTRUMENTED='NO', HISTORY='YES'
51  where PROCESSLIST_ID = connection_id();
52
53let $con3_thread_id= `select THREAD_ID from performance_schema.threads
54  where PROCESSLIST_ID = connection_id()`;
55
56--echo # Switch to (con4, localhost, user4, , )
57connect (con4, localhost, user4, , );
58
59update performance_schema.threads
60  set INSTRUMENTED='NO', HISTORY='NO'
61  where PROCESSLIST_ID = connection_id();
62
63let $con4_thread_id= `select THREAD_ID from performance_schema.threads
64  where PROCESSLIST_ID = connection_id()`;
65
66--echo # Switch to connection default
67--connection default
68
69truncate table performance_schema.events_transactions_current;
70truncate table performance_schema.events_transactions_history;
71truncate table performance_schema.events_transactions_history_long;
72truncate table performance_schema.events_statements_current;
73truncate table performance_schema.events_statements_history;
74truncate table performance_schema.events_statements_history_long;
75truncate table performance_schema.events_stages_current;
76truncate table performance_schema.events_stages_history;
77truncate table performance_schema.events_stages_history_long;
78truncate table performance_schema.events_waits_current;
79truncate table performance_schema.events_waits_history;
80truncate table performance_schema.events_waits_history_long;
81
82--echo # Switch to connection con1
83--connection con1
84
85XA START 'XA_CON1', 'XA_BQUAL', 12;
86select "Hi from con1";
87XA END 'XA_CON1', 'XA_BQUAL', 12;
88XA PREPARE 'XA_CON1', 'XA_BQUAL', 12;
89XA COMMIT 'XA_CON1', 'XA_BQUAL', 12;
90
91--echo # Switch to connection con2
92--connection con2
93
94XA START 'XA_CON2', 'XA_BQUAL', 12;
95select "Hi from con2";
96XA END 'XA_CON2', 'XA_BQUAL', 12;
97XA PREPARE 'XA_CON2', 'XA_BQUAL', 12;
98XA COMMIT 'XA_CON2', 'XA_BQUAL', 12;
99
100--echo # Switch to connection con3
101--connection con3
102
103XA START 'XA_CON3', 'XA_BQUAL', 12;
104select "Hi from con3";
105XA END 'XA_CON3', 'XA_BQUAL', 12;
106XA PREPARE 'XA_CON3', 'XA_BQUAL', 12;
107XA COMMIT 'XA_CON3', 'XA_BQUAL', 12;
108
109--echo # Switch to connection con4
110--connection con4
111
112XA START 'XA_CON4', 'XA_BQUAL', 12;
113select "Hi from con4";
114XA END 'XA_CON4', 'XA_BQUAL', 12;
115XA PREPARE 'XA_CON4', 'XA_BQUAL', 12;
116XA COMMIT 'XA_CON4', 'XA_BQUAL', 12;
117
118--connection default
119
120--disable_query_log
121
122echo "=========================== Transactions user 1";
123
124eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
125  where THREAD_ID = $con1_thread_id;
126eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history
127  where THREAD_ID = $con1_thread_id;
128eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long
129  where THREAD_ID = $con1_thread_id;
130
131echo "=========================== Transactions user 2";
132
133eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
134  where THREAD_ID = $con2_thread_id;
135eval select count(*) from performance_schema.events_transactions_history
136  where THREAD_ID = $con2_thread_id;
137eval select count(*) from performance_schema.events_transactions_history_long
138  where THREAD_ID = $con2_thread_id;
139
140echo "=========================== Transactions user 3";
141
142eval select count(*) from performance_schema.events_transactions_current
143  where THREAD_ID = $con3_thread_id;
144eval select count(*) from performance_schema.events_transactions_history
145  where THREAD_ID = $con3_thread_id;
146eval select count(*) from performance_schema.events_transactions_history_long
147  where THREAD_ID = $con3_thread_id;
148
149echo "=========================== Transactions user 4";
150
151eval select count(*) from performance_schema.events_transactions_current
152  where THREAD_ID = $con4_thread_id;
153eval select count(*) from performance_schema.events_transactions_history
154  where THREAD_ID = $con4_thread_id;
155eval select count(*) from performance_schema.events_transactions_history_long
156  where THREAD_ID = $con4_thread_id;
157
158echo "=========================== Statements user 1";
159
160eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
161  where THREAD_ID = $con1_thread_id
162  order by THREAD_ID, EVENT_ID;
163eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history
164  where THREAD_ID = $con1_thread_id
165  order by THREAD_ID, EVENT_ID;
166eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long
167  where THREAD_ID = $con1_thread_id
168  order by THREAD_ID, EVENT_ID;
169
170echo "=========================== Statements user 2";
171
172eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
173  where THREAD_ID = $con2_thread_id
174  order by THREAD_ID, EVENT_ID;
175eval select count(*) from performance_schema.events_statements_history
176  where THREAD_ID = $con2_thread_id;
177eval select count(*) from performance_schema.events_statements_history_long
178  where THREAD_ID = $con2_thread_id;
179
180echo "=========================== Statements user 3";
181
182eval select count(*) from performance_schema.events_statements_current
183  where THREAD_ID = $con3_thread_id;
184eval select count(*) from performance_schema.events_statements_history
185  where THREAD_ID = $con3_thread_id;
186eval select count(*) from performance_schema.events_statements_history_long
187  where THREAD_ID = $con3_thread_id;
188
189echo "=========================== Statements user 4";
190
191eval select count(*) from performance_schema.events_statements_current
192  where THREAD_ID = $con4_thread_id;
193eval select count(*) from performance_schema.events_statements_history
194  where THREAD_ID = $con4_thread_id;
195eval select count(*) from performance_schema.events_statements_history_long
196  where THREAD_ID = $con4_thread_id;
197
198echo "=========================== Stages user 1";
199
200eval select EVENT_NAME from performance_schema.events_stages_current
201  where THREAD_ID = $con1_thread_id
202  order by THREAD_ID, EVENT_ID;
203eval select EVENT_NAME from performance_schema.events_stages_history
204  where THREAD_ID = $con1_thread_id
205  order by THREAD_ID, EVENT_ID;
206eval select EVENT_NAME from performance_schema.events_stages_history_long
207  where THREAD_ID = $con1_thread_id
208  order by THREAD_ID, EVENT_ID;
209
210echo "=========================== Stages user 2";
211
212eval select EVENT_NAME from performance_schema.events_stages_current
213  where THREAD_ID = $con2_thread_id
214  order by THREAD_ID, EVENT_ID;
215eval select count(*) from performance_schema.events_stages_history
216  where THREAD_ID = $con2_thread_id;
217eval select count(*) from performance_schema.events_stages_history_long
218  where THREAD_ID = $con2_thread_id;
219
220echo "=========================== Stages user 3";
221
222eval select count(*) from performance_schema.events_stages_current
223  where THREAD_ID = $con3_thread_id;
224eval select count(*) from performance_schema.events_stages_history
225  where THREAD_ID = $con3_thread_id;
226eval select count(*) from performance_schema.events_stages_history_long
227  where THREAD_ID = $con3_thread_id;
228
229echo "=========================== Stages user 4";
230
231eval select count(*) from performance_schema.events_stages_current
232  where THREAD_ID = $con4_thread_id;
233eval select count(*) from performance_schema.events_stages_history
234  where THREAD_ID = $con4_thread_id;
235eval select count(*) from performance_schema.events_stages_history_long
236  where THREAD_ID = $con4_thread_id;
237
238echo "=========================== Waits user 1";
239
240eval select EVENT_NAME from performance_schema.events_waits_current
241  where THREAD_ID = $con1_thread_id
242  order by THREAD_ID, EVENT_ID;
243eval select (count(*) > 5) as has_waits from performance_schema.events_waits_history
244  where THREAD_ID = $con1_thread_id;
245eval select (count(*) > 15) as has_waits from performance_schema.events_waits_history_long
246  where THREAD_ID = $con1_thread_id;
247
248echo "=========================== Waits user 2";
249
250eval select EVENT_NAME from performance_schema.events_waits_current
251  where THREAD_ID = $con2_thread_id
252  order by THREAD_ID, EVENT_ID;
253eval select count(*) from performance_schema.events_waits_history
254  where THREAD_ID = $con2_thread_id;
255eval select count(*) from performance_schema.events_waits_history_long
256  where THREAD_ID = $con2_thread_id;
257
258echo "=========================== Waits user 3";
259
260eval select count(*) from performance_schema.events_waits_current
261  where THREAD_ID = $con3_thread_id;
262eval select count(*) from performance_schema.events_waits_history
263  where THREAD_ID = $con3_thread_id;
264eval select count(*) from performance_schema.events_waits_history_long
265  where THREAD_ID = $con3_thread_id;
266
267echo "=========================== Waits user 4";
268
269eval select count(*) from performance_schema.events_waits_current
270  where THREAD_ID = $con4_thread_id;
271eval select count(*) from performance_schema.events_waits_history
272  where THREAD_ID = $con4_thread_id;
273eval select count(*) from performance_schema.events_waits_history_long
274  where THREAD_ID = $con4_thread_id;
275
276--enable_query_log
277
278--echo # Switch to connection default, disable consumers
279--connection default
280
281update performance_schema.setup_consumers
282  set enabled='NO' where name like "%history%";
283
284select * from performance_schema.setup_consumers;
285
286truncate table performance_schema.events_transactions_current;
287truncate table performance_schema.events_transactions_history;
288truncate table performance_schema.events_transactions_history_long;
289truncate table performance_schema.events_statements_current;
290truncate table performance_schema.events_statements_history;
291truncate table performance_schema.events_statements_history_long;
292truncate table performance_schema.events_stages_current;
293truncate table performance_schema.events_stages_history;
294truncate table performance_schema.events_stages_history_long;
295truncate table performance_schema.events_waits_current;
296truncate table performance_schema.events_waits_history;
297truncate table performance_schema.events_waits_history_long;
298
299--echo # Switch to connection con1
300--connection con1
301
302XA START 'XA_CON1', 'XA_BQUAL', 12;
303select "Hi from con1";
304XA END 'XA_CON1', 'XA_BQUAL', 12;
305XA PREPARE 'XA_CON1', 'XA_BQUAL', 12;
306XA COMMIT 'XA_CON1', 'XA_BQUAL', 12;
307
308--echo # Switch to connection con2
309--connection con2
310
311XA START 'XA_CON2', 'XA_BQUAL', 12;
312select "Hi from con2";
313XA END 'XA_CON2', 'XA_BQUAL', 12;
314XA PREPARE 'XA_CON2', 'XA_BQUAL', 12;
315XA COMMIT 'XA_CON2', 'XA_BQUAL', 12;
316
317--echo # Switch to connection con3
318--connection con3
319
320XA START 'XA_CON3', 'XA_BQUAL', 12;
321select "Hi from con3";
322XA END 'XA_CON3', 'XA_BQUAL', 12;
323XA PREPARE 'XA_CON3', 'XA_BQUAL', 12;
324XA COMMIT 'XA_CON3', 'XA_BQUAL', 12;
325
326--echo # Switch to connection con4
327--connection con4
328
329XA START 'XA_CON4', 'XA_BQUAL', 12;
330select "Hi from con4";
331XA END 'XA_CON4', 'XA_BQUAL', 12;
332XA PREPARE 'XA_CON4', 'XA_BQUAL', 12;
333XA COMMIT 'XA_CON4', 'XA_BQUAL', 12;
334
335--connection default
336
337--disable_query_log
338
339echo "=========================== Transactions user 1";
340
341eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
342  where THREAD_ID = $con1_thread_id;
343eval select count(*) from performance_schema.events_transactions_history
344  where THREAD_ID = $con1_thread_id;
345eval select count(*) from performance_schema.events_transactions_history_long
346  where THREAD_ID = $con1_thread_id;
347
348echo "=========================== Transactions user 2";
349
350eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
351  where THREAD_ID = $con2_thread_id;
352eval select count(*) from performance_schema.events_transactions_history
353  where THREAD_ID = $con2_thread_id;
354eval select count(*) from performance_schema.events_transactions_history_long
355  where THREAD_ID = $con2_thread_id;
356
357echo "=========================== Transactions user 3";
358
359eval select count(*) from performance_schema.events_transactions_current
360  where THREAD_ID = $con3_thread_id;
361eval select count(*) from performance_schema.events_transactions_history
362  where THREAD_ID = $con3_thread_id;
363eval select count(*) from performance_schema.events_transactions_history_long
364  where THREAD_ID = $con3_thread_id;
365
366echo "=========================== Transactions user 4";
367
368eval select count(*) from performance_schema.events_transactions_current
369  where THREAD_ID = $con4_thread_id;
370eval select count(*) from performance_schema.events_transactions_history
371  where THREAD_ID = $con4_thread_id;
372eval select count(*) from performance_schema.events_transactions_history_long
373  where THREAD_ID = $con4_thread_id;
374
375echo "=========================== Statements user 1";
376
377eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
378  where THREAD_ID = $con1_thread_id
379  order by THREAD_ID, EVENT_ID;
380eval select count(*) from performance_schema.events_statements_history
381  where THREAD_ID = $con1_thread_id;
382eval select count(*) from performance_schema.events_statements_history_long
383  where THREAD_ID = $con1_thread_id;
384
385echo "=========================== Statements user 2";
386
387eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
388  where THREAD_ID = $con2_thread_id
389  order by THREAD_ID, EVENT_ID;
390eval select count(*) from performance_schema.events_statements_history
391  where THREAD_ID = $con2_thread_id;
392eval select count(*) from performance_schema.events_statements_history_long
393  where THREAD_ID = $con2_thread_id;
394
395echo "=========================== Statements user 3";
396
397eval select count(*) from performance_schema.events_statements_current
398  where THREAD_ID = $con3_thread_id;
399eval select count(*) from performance_schema.events_statements_history
400  where THREAD_ID = $con3_thread_id;
401eval select count(*) from performance_schema.events_statements_history_long
402  where THREAD_ID = $con3_thread_id;
403
404echo "=========================== Statements user 4";
405
406eval select count(*) from performance_schema.events_statements_current
407  where THREAD_ID = $con4_thread_id;
408eval select count(*) from performance_schema.events_statements_history
409  where THREAD_ID = $con4_thread_id;
410eval select count(*) from performance_schema.events_statements_history_long
411  where THREAD_ID = $con4_thread_id;
412
413echo "=========================== Stages user 1";
414
415eval select EVENT_NAME from performance_schema.events_stages_current
416  where THREAD_ID = $con1_thread_id
417  order by THREAD_ID, EVENT_ID;
418eval select count(*) from performance_schema.events_stages_history
419  where THREAD_ID = $con1_thread_id;
420eval select count(*) from performance_schema.events_stages_history_long
421  where THREAD_ID = $con1_thread_id;
422
423echo "=========================== Stages user 2";
424
425eval select EVENT_NAME from performance_schema.events_stages_current
426  where THREAD_ID = $con2_thread_id
427  order by THREAD_ID, EVENT_ID;
428eval select count(*) from performance_schema.events_stages_history
429  where THREAD_ID = $con2_thread_id;
430eval select count(*) from performance_schema.events_stages_history_long
431  where THREAD_ID = $con2_thread_id;
432
433echo "=========================== Stages user 3";
434
435eval select count(*) from performance_schema.events_stages_current
436  where THREAD_ID = $con3_thread_id;
437eval select count(*) from performance_schema.events_stages_history
438  where THREAD_ID = $con3_thread_id;
439eval select count(*) from performance_schema.events_stages_history_long
440  where THREAD_ID = $con3_thread_id;
441
442echo "=========================== Stages user 4";
443
444eval select count(*) from performance_schema.events_stages_current
445  where THREAD_ID = $con4_thread_id;
446eval select count(*) from performance_schema.events_stages_history
447  where THREAD_ID = $con4_thread_id;
448eval select count(*) from performance_schema.events_stages_history_long
449  where THREAD_ID = $con4_thread_id;
450
451echo "=========================== Waits user 1";
452
453eval select EVENT_NAME from performance_schema.events_waits_current
454  where THREAD_ID = $con1_thread_id
455  order by THREAD_ID, EVENT_ID;
456eval select count(*) as has_waits from performance_schema.events_waits_history
457  where THREAD_ID = $con1_thread_id;
458eval select count(*) as has_waits from performance_schema.events_waits_history_long
459  where THREAD_ID = $con1_thread_id;
460
461echo "=========================== Waits user 2";
462
463eval select EVENT_NAME from performance_schema.events_waits_current
464  where THREAD_ID = $con2_thread_id
465  order by THREAD_ID, EVENT_ID;
466eval select count(*) from performance_schema.events_waits_history
467  where THREAD_ID = $con2_thread_id;
468eval select count(*) from performance_schema.events_waits_history_long
469  where THREAD_ID = $con2_thread_id;
470
471echo "=========================== Waits user 3";
472
473eval select count(*) from performance_schema.events_waits_current
474  where THREAD_ID = $con3_thread_id;
475eval select count(*) from performance_schema.events_waits_history
476  where THREAD_ID = $con3_thread_id;
477eval select count(*) from performance_schema.events_waits_history_long
478  where THREAD_ID = $con3_thread_id;
479
480echo "=========================== Waits user 4";
481
482eval select count(*) from performance_schema.events_waits_current
483  where THREAD_ID = $con4_thread_id;
484eval select count(*) from performance_schema.events_waits_history
485  where THREAD_ID = $con4_thread_id;
486eval select count(*) from performance_schema.events_waits_history_long
487  where THREAD_ID = $con4_thread_id;
488
489--enable_query_log
490
491--echo # Switch to connection default, enable consumers
492--connection default
493
494update performance_schema.setup_consumers
495  set enabled='YES' where name like "%history%";
496
497select * from performance_schema.setup_consumers;
498
499truncate table performance_schema.events_transactions_current;
500truncate table performance_schema.events_transactions_history;
501truncate table performance_schema.events_transactions_history_long;
502truncate table performance_schema.events_statements_current;
503truncate table performance_schema.events_statements_history;
504truncate table performance_schema.events_statements_history_long;
505truncate table performance_schema.events_stages_current;
506truncate table performance_schema.events_stages_history;
507truncate table performance_schema.events_stages_history_long;
508truncate table performance_schema.events_waits_current;
509truncate table performance_schema.events_waits_history;
510truncate table performance_schema.events_waits_history_long;
511
512--echo # Switch to connection con1
513--connection con1
514
515XA START 'XA_CON1', 'XA_BQUAL', 12;
516select "Hi from con1";
517XA END 'XA_CON1', 'XA_BQUAL', 12;
518XA PREPARE 'XA_CON1', 'XA_BQUAL', 12;
519XA COMMIT 'XA_CON1', 'XA_BQUAL', 12;
520
521--echo # Switch to connection con2
522--connection con2
523
524XA START 'XA_CON2', 'XA_BQUAL', 12;
525select "Hi from con2";
526XA END 'XA_CON2', 'XA_BQUAL', 12;
527XA PREPARE 'XA_CON2', 'XA_BQUAL', 12;
528XA COMMIT 'XA_CON2', 'XA_BQUAL', 12;
529
530--echo # Switch to connection con3
531--connection con3
532
533XA START 'XA_CON3', 'XA_BQUAL', 12;
534select "Hi from con3";
535XA END 'XA_CON3', 'XA_BQUAL', 12;
536XA PREPARE 'XA_CON3', 'XA_BQUAL', 12;
537XA COMMIT 'XA_CON3', 'XA_BQUAL', 12;
538
539--echo # Switch to connection con4
540--connection con4
541
542XA START 'XA_CON4', 'XA_BQUAL', 12;
543select "Hi from con4";
544XA END 'XA_CON4', 'XA_BQUAL', 12;
545XA PREPARE 'XA_CON4', 'XA_BQUAL', 12;
546XA COMMIT 'XA_CON4', 'XA_BQUAL', 12;
547
548--connection default
549
550--disable_query_log
551
552echo "=========================== Transactions user 1";
553
554eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
555  where THREAD_ID = $con1_thread_id;
556eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history
557  where THREAD_ID = $con1_thread_id;
558eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long
559  where THREAD_ID = $con1_thread_id;
560
561echo "=========================== Transactions user 2";
562
563eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
564  where THREAD_ID = $con2_thread_id;
565eval select count(*) from performance_schema.events_transactions_history
566  where THREAD_ID = $con2_thread_id;
567eval select count(*) from performance_schema.events_transactions_history_long
568  where THREAD_ID = $con2_thread_id;
569
570echo "=========================== Transactions user 3";
571
572eval select count(*) from performance_schema.events_transactions_current
573  where THREAD_ID = $con3_thread_id;
574eval select count(*) from performance_schema.events_transactions_history
575  where THREAD_ID = $con3_thread_id;
576eval select count(*) from performance_schema.events_transactions_history_long
577  where THREAD_ID = $con3_thread_id;
578
579echo "=========================== Transactions user 4";
580
581eval select count(*) from performance_schema.events_transactions_current
582  where THREAD_ID = $con4_thread_id;
583eval select count(*) from performance_schema.events_transactions_history
584  where THREAD_ID = $con4_thread_id;
585eval select count(*) from performance_schema.events_transactions_history_long
586  where THREAD_ID = $con4_thread_id;
587
588echo "=========================== Statements user 1";
589
590eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
591  where THREAD_ID = $con1_thread_id
592  order by THREAD_ID, EVENT_ID;
593eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history
594  where THREAD_ID = $con1_thread_id
595  order by THREAD_ID, EVENT_ID;
596eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long
597  where THREAD_ID = $con1_thread_id
598  order by THREAD_ID, EVENT_ID;
599
600echo "=========================== Statements user 2";
601
602eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
603  where THREAD_ID = $con2_thread_id
604  order by THREAD_ID, EVENT_ID;
605eval select count(*) from performance_schema.events_statements_history
606  where THREAD_ID = $con2_thread_id;
607eval select count(*) from performance_schema.events_statements_history_long
608  where THREAD_ID = $con2_thread_id;
609
610echo "=========================== Statements user 3";
611
612eval select count(*) from performance_schema.events_statements_current
613  where THREAD_ID = $con3_thread_id;
614eval select count(*) from performance_schema.events_statements_history
615  where THREAD_ID = $con3_thread_id;
616eval select count(*) from performance_schema.events_statements_history_long
617  where THREAD_ID = $con3_thread_id;
618
619echo "=========================== Statements user 4";
620
621eval select count(*) from performance_schema.events_statements_current
622  where THREAD_ID = $con4_thread_id;
623eval select count(*) from performance_schema.events_statements_history
624  where THREAD_ID = $con4_thread_id;
625eval select count(*) from performance_schema.events_statements_history_long
626  where THREAD_ID = $con4_thread_id;
627
628echo "=========================== Stages user 1";
629
630eval select EVENT_NAME from performance_schema.events_stages_current
631  where THREAD_ID = $con1_thread_id
632  order by THREAD_ID, EVENT_ID;
633eval select EVENT_NAME from performance_schema.events_stages_history
634  where THREAD_ID = $con1_thread_id
635  order by THREAD_ID, EVENT_ID;
636eval select EVENT_NAME from performance_schema.events_stages_history_long
637  where THREAD_ID = $con1_thread_id
638  order by THREAD_ID, EVENT_ID;
639
640echo "=========================== Stages user 2";
641
642eval select EVENT_NAME from performance_schema.events_stages_current
643  where THREAD_ID = $con2_thread_id
644  order by THREAD_ID, EVENT_ID;
645eval select count(*) from performance_schema.events_stages_history
646  where THREAD_ID = $con2_thread_id;
647eval select count(*) from performance_schema.events_stages_history_long
648  where THREAD_ID = $con2_thread_id;
649
650echo "=========================== Stages user 3";
651
652eval select count(*) from performance_schema.events_stages_current
653  where THREAD_ID = $con3_thread_id;
654eval select count(*) from performance_schema.events_stages_history
655  where THREAD_ID = $con3_thread_id;
656eval select count(*) from performance_schema.events_stages_history_long
657  where THREAD_ID = $con3_thread_id;
658
659echo "=========================== Stages user 4";
660
661eval select count(*) from performance_schema.events_stages_current
662  where THREAD_ID = $con4_thread_id;
663eval select count(*) from performance_schema.events_stages_history
664  where THREAD_ID = $con4_thread_id;
665eval select count(*) from performance_schema.events_stages_history_long
666  where THREAD_ID = $con4_thread_id;
667
668echo "=========================== Waits user 1";
669
670eval select EVENT_NAME from performance_schema.events_waits_current
671  where THREAD_ID = $con1_thread_id
672  order by THREAD_ID, EVENT_ID;
673eval select (count(*) > 5) as has_waits from performance_schema.events_waits_history
674  where THREAD_ID = $con1_thread_id;
675eval select (count(*) > 15) as has_waits from performance_schema.events_waits_history_long
676  where THREAD_ID = $con1_thread_id;
677
678echo "=========================== Waits user 2";
679
680eval select EVENT_NAME from performance_schema.events_waits_current
681  where THREAD_ID = $con2_thread_id
682  order by THREAD_ID, EVENT_ID;
683eval select count(*) from performance_schema.events_waits_history
684  where THREAD_ID = $con2_thread_id;
685eval select count(*) from performance_schema.events_waits_history_long
686  where THREAD_ID = $con2_thread_id;
687
688echo "=========================== Waits user 3";
689
690eval select count(*) from performance_schema.events_waits_current
691  where THREAD_ID = $con3_thread_id;
692eval select count(*) from performance_schema.events_waits_history
693  where THREAD_ID = $con3_thread_id;
694eval select count(*) from performance_schema.events_waits_history_long
695  where THREAD_ID = $con3_thread_id;
696
697echo "=========================== Waits user 4";
698
699eval select count(*) from performance_schema.events_waits_current
700  where THREAD_ID = $con4_thread_id;
701eval select count(*) from performance_schema.events_waits_history
702  where THREAD_ID = $con4_thread_id;
703eval select count(*) from performance_schema.events_waits_history_long
704  where THREAD_ID = $con4_thread_id;
705
706--enable_query_log
707
708--echo # Switch to connection default
709--connection default
710
711revoke all privileges, grant option from user1@localhost;
712revoke all privileges, grant option from user2@localhost;
713revoke all privileges, grant option from user3@localhost;
714revoke all privileges, grant option from user4@localhost;
715drop user user1@localhost;
716drop user user2@localhost;
717drop user user3@localhost;
718drop user user4@localhost;
719flush privileges;
720
721truncate table performance_schema.setup_actors;
722
723insert into performance_schema.setup_actors
724values ('%', '%', '%', 'YES', 'YES');
725
726select * from performance_schema.setup_actors;
727
728