1########### ../t/admin_xkill.test                            #########
2##                                                                   #
3## This test aims to run list_clients and kill_client admin commands #
4## Test runs covers below scenarios:                                 #
5##  - listing client with single session and multiple sessions       #
6##  - killing own session and root user session with privileged user #
7##  - killing own session and root user session with unprivileged user
8##  - killing session with value of different data types than UINT   #
9##  - killing root session with user has only process privilege      #
10##  - listing and killing session with password expired user         #
11##  - killing valid sql_session id with xprotocol connection         #
12##  - listing and killing default mysqlx_max_connections ie 100      #
13##  - listing,killing clients with ssl xprotocol privileged conn     #
14##  - listing and killing clients with ssl xprotocol root connection #
15##  - kill_client,list_clients stats with show_compatibility_56='ON' #
16##  - kill_client,list_clients stats with show_compatibility_56='OFF'#
17##  - check sum of these 2 vars with all mysqlx sessions should be as#
18#        that of with mysql client                                   #
19######################################################################
20
21--source ../include/xplugin_preamble.inc
22call mtr.add_suppression("Plugin mysqlx reported: 'Unhandled network error: Bad file descriptor'");
23create user sslcon@localhost identified by 'sslcon';
24grant all on *.* to sslcon@localhost;
25--write_file $MYSQL_TMP_DIR/admin_xkill.tmp
26-->sql
27create user abc@localhost identified by 'abc';
28create user xplugin@localhost identified by 'xplugin';
29grant all on *.* to xplugin@localhost;
30create user process@localhost identified by 'process';
31grant process on *.* to process@localhost;
32create user expire@localhost identified by 'expire';
33grant all on *.* to expire@localhost;
34alter user expire@localhost password expire;
35select sleep(1);
36-->endsql
37-->echo Test data
38Mysqlx.Sql.StmtExecute {
39  stmt: "list_clients"
40  namespace: "xplugin"
41}
42
43-->echo expect Mysqlx.Sql.StmtExecuteOk
44-->recvresult
45
46-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0
47-->sql
48show status like 'Mysqlx%client%';
49-->endsql
50
51-->echo create and activate new session
52-->newsession aux	root
53
54Mysqlx.Sql.StmtExecute {
55  stmt: "list_clients"
56  namespace: "xplugin"
57}
58
59-->echo expect Mysqlx.Sql.StmtExecuteOk
60-->recvresult client_id user host
61
62-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0 even with another new root session
63-->sql
64show status like 'Mysqlx%client%';
65-->endsql
66
67-->echo switch back to default session
68-->setsession
69
70Mysqlx.Sql.StmtExecute {
71  stmt: "list_clients"
72  namespace: "xplugin"
73}
74
75-->echo expect Mysqlx.Sql.StmtExecuteOk
76-->recvresult client_id user host
77
78-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=0 with default root session where list_clients already executed
79-->sql
80show status like 'Mysqlx%client%';
81-->endsql
82
83Mysqlx.Sql.StmtExecute {
84  stmt: "kill_client"
85  namespace: "xplugin"
86  args {
87    type: SCALAR
88    scalar {
89      type: V_UINT
90      v_unsigned_int: 2
91    }
92  }
93}
94-->recvresult
95
96-->sql
97select sleep(0.5);
98-->endsql
99
100Mysqlx.Sql.StmtExecute {
101  stmt: "list_clients"
102  namespace: "xplugin"
103}
104
105-->echo expect Mysqlx.Sql.StmtExecuteOk
106-->recvresult client_id user host
107
108-->echo expect Mysqlx_stmt_list_clients=3 and Mysqlx_stmt_kill_client=1 with default root session where list_clients executed 3 times and kill_client once
109-->sql
110show status like 'Mysqlx%client%';
111-->endsql
112
113-->echo create and activate new session abc
114-->echo expect only abc user session id
115-->newsession abc	abc	abc
116
117Mysqlx.Sql.StmtExecute {
118  stmt: "list_clients"
119  namespace: "xplugin"
120}
121
122-->echo expect Mysqlx.Sql.StmtExecuteOk
123-->recvresult client_id user host
124
125-->echo killing root user session with unprivileged user 'abc' which should be unsuccessful
126Mysqlx.Sql.StmtExecute {
127  stmt: "kill_client"
128  namespace: "xplugin"
129  args {
130    type: SCALAR
131    scalar {
132      type: V_UINT
133      v_unsigned_int: 1
134    }
135  }
136}
137
138-->echo expect Mysqlx.Sql.StmtExecuteOk
139-->expecterror 1095
140-->recvresult
141
142-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=1 with session abc where list_clients and kill_client executed once
143-->sql
144select sleep(0.5);
145show status like 'Mysqlx%client%';
146select user(),current_user();
147show grants;
148-->endsql
149
150-->echo open another session of abc user and kill first session of abc user,which should be successful
151-->newsession abc1	abc	abc
152
153Mysqlx.Sql.StmtExecute {
154  stmt: "list_clients"
155  namespace: "xplugin"
156}
157
158-->recvresult client_id user host
159
160Mysqlx.Sql.StmtExecute {
161  stmt: "kill_client"
162  namespace: "xplugin"
163  args {
164    type: SCALAR
165    scalar {
166      type: V_UINT
167      v_unsigned_int: 3
168    }
169  }
170}
171-->recvresult
172
173-->sql
174select sleep(0.5);
175-->endsql
176
177Mysqlx.Sql.StmtExecute {
178  stmt: "list_clients"
179  namespace: "xplugin"
180}
181
182-->recvresult client_id user host
183
184-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=1 with new session abc where list_clients executed twice and kill_client executed once
185-->sql
186show status like 'Mysqlx%client%';
187select user(),current_user();
188show grants;
189-->endsql
190
191-->echo killing abc user session with its own session 'abc' which should be successful
192-->echo expect right error instead of End of File
193Mysqlx.Sql.StmtExecute {
194  stmt: "kill_client"
195  namespace: "xplugin"
196  args {
197    type: SCALAR
198    scalar {
199      type: V_UINT
200      v_unsigned_int: 4
201    }
202  }
203}
204
205#-->echo expect Mysqlx.Sql.StmtExecuteOk
206#-->recvresult
207# and switch back to default
208-->recvuntildisc
209
210-->sql
211select sleep(0.5);
212-->endsql
213
214-->echo switch back to default session
215-->setsession
216
217Mysqlx.Sql.StmtExecute {
218  stmt: "list_clients"
219  namespace: "xplugin"
220}
221
222-->echo expect Mysqlx.Sql.StmtExecuteOk
223-->recvresult client_id user host
224
225-->echo expect Mysqlx_stmt_list_clients=4 and Mysqlx_stmt_kill_client=1 with default root session where list_clients executed 4 times and kill_client once
226-->sql
227show status like 'Mysqlx%client%';
228select user(),current_user();
229show grants;
230-->endsql
231
232-->echo open process only privileged user seession and kill root user session,expect error "You are not owner of thread"
233-->newsession process	process	process
234
235Mysqlx.Sql.StmtExecute {
236  stmt: "list_clients"
237  namespace: "xplugin"
238}
239-->recvresult client_id user host
240
241Mysqlx.Sql.StmtExecute {
242  stmt: "kill_client"
243  namespace: "xplugin"
244  args {
245    type: SCALAR
246    scalar {
247      type: V_UINT
248      v_unsigned_int: 1
249    }
250  }
251}
252
253-->echo expect Mysqlx.Sql.StmtExecuteOk
254-->expecterror 1095
255-->recvresult
256
257-->sleep 1
258
259-->echo checking list of clients after root user session killed by xplugin user
260Mysqlx.Sql.StmtExecute {
261  stmt: "list_clients"
262  namespace: "xplugin"
263}
264
265-->recvresult client_id user host
266
267-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=1 with process user where list_clients executed 2 times and kill_client once
268-->sql
269show status like 'Mysqlx%client%';
270select user(),current_user();
271show grants;
272-->endsql
273
274-->echo open privileged user seession and kill root user session,expect success
275-->newsession xplugin	xplugin	xplugin
276
277Mysqlx.Sql.StmtExecute {
278  stmt: "list_clients"
279  namespace: "xplugin"
280}
281
282-->recvresult client_id user host
283
284Mysqlx.Sql.StmtExecute {
285  stmt: "kill_client"
286  namespace: "xplugin"
287  args {
288    type: SCALAR
289    scalar {
290      type: V_UINT
291      v_unsigned_int: 1
292    }
293  }
294}
295-->echo expect Mysqlx.Sql.StmtExecuteOk
296-->recvresult
297
298-->sql
299select sleep(0.5);
300-->endsql
301
302-->echo checking list of clients after root user session killed by xplugin user
303Mysqlx.Sql.StmtExecute {
304  stmt: "list_clients"
305  namespace: "xplugin"
306}
307
308-->recvresult client_id user host
309
310-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=1 with xplugin user where list_clients executed 2 times and kill_client once
311-->sql
312show status like 'Mysqlx%client%';
313select user(),current_user();
314show grants;
315-->endsql
316
317-->echo Cleanup
318-->sql
319drop schema if exists xtest;
320#show status like 'Mysqlx%client%';
321-->endsql
322EOF
323
324## killing client with invalid scalar data types
325--write_file $MYSQL_TMP_DIR/admin_xkill_invaliddtype.tmp
326Mysqlx.Sql.StmtExecute {
327  stmt: "list_clients"
328  namespace: "xplugin"
329}
330
331-->echo expect Mysqlx.Sql.StmtExecuteOk
332-->recvresult client_id user host
333
334-->echo expect error while killing client with data type other than usinged int
335-->echo try killing xprotocol session with valid sql_session id once xprotocol connetion opened with kill_client,expect error
336
337Mysqlx.Sql.StmtExecute {
338  stmt: "kill_client"
339  namespace: "xplugin"
340  args {
341    type: SCALAR
342    scalar {
343      type: V_UINT
344      v_unsigned_int: 11
345    }
346  }
347}
348
349-->echo expect Mysqlx.Sql.StmtExecuteOk
350-->expecterror 1094
351-->recvresult
352
353Mysqlx.Sql.StmtExecute {
354  stmt: "kill_client"
355  namespace: "xplugin"
356  args {
357    type: SCALAR
358    scalar {
359          type: V_STRING
360          v_string:{
361            value: "1"
362          }
363     }
364  }
365}
366-->expecterror 5016
367-->recvresult
368
369Mysqlx.Sql.StmtExecute {
370  stmt: "kill_client"
371  namespace: "xplugin"
372  args {
373    type: SCALAR
374    scalar {
375          type: V_BOOL
376          v_bool:1
377     }
378  }
379}
380-->expecterror 5016
381-->recvresult
382
383Mysqlx.Sql.StmtExecute {
384  stmt: "kill_client"
385  namespace: "xplugin"
386  args {
387    type: SCALAR
388    scalar {
389          type: V_BOOL
390          v_bool:0
391     }
392  }
393}
394-->expecterror 5016
395-->recvresult
396
397Mysqlx.Sql.StmtExecute {
398  stmt: "kill_client"
399  namespace: "xplugin"
400  args {
401    type: SCALAR
402    scalar {
403          type: V_BOOL
404          v_bool:false
405     }
406  }
407}
408-->expecterror 5016
409-->recvresult
410
411Mysqlx.Sql.StmtExecute {
412  stmt: "kill_client"
413  namespace: "xplugin"
414  args {
415    type: SCALAR
416    scalar {
417          type: V_BOOL
418          v_bool:true
419     }
420  }
421}
422-->expecterror 5016
423-->recvresult
424
425Mysqlx.Sql.StmtExecute {
426  stmt: "kill_client"
427  namespace: "xplugin"
428  args {
429    type: SCALAR
430    scalar {
431          type: V_FLOAT
432          v_float:1
433     }
434  }
435}
436-->expecterror 5016
437-->recvresult
438
439Mysqlx.Sql.StmtExecute {
440  stmt: "kill_client"
441  namespace: "xplugin"
442  args {
443    type: SCALAR
444    scalar {
445          type: V_DOUBLE
446          v_double:1
447     }
448  }
449}
450-->expecterror 5016
451-->recvresult
452
453Mysqlx.Sql.StmtExecute {
454  stmt: "kill_client"
455  namespace: "xplugin"
456  args {
457    type: SCALAR
458    scalar {
459          type: V_NULL
460     }
461  }
462}
463-->expecterror 5016
464-->recvresult
465
466Mysqlx.Sql.StmtExecute {
467  stmt: "kill_client"
468  namespace: "xplugin"
469  args {
470    type: SCALAR
471    scalar {
472          type: V_OCTETS
473          v_octets {value:"1"}
474     }
475  }
476}
477-->expecterror 5016
478-->recvresult
479
480Mysqlx.Sql.StmtExecute {
481  stmt: "kill_client"
482  namespace: "xplugin"
483  args {
484    type: SCALAR
485    scalar {
486          type: V_SINT
487          v_signed_int:-1
488     }
489  }
490}
491-->expecterror 5016
492-->recvresult
493
494-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=11 with root user even though kill_client returns errors
495-->sql
496show status like 'Mysqlx%client%';
497-->endsql
498
499EOF
500
501--write_file $MYSQL_TMP_DIR/admin_xkill_pwd_expire.tmp
502-->echo expect error if list_clients and kill_client executed from password expired user session
503-->expecterror 1820
504-->sql
505show processlist;
506-->endsql
507
508Mysqlx.Sql.StmtExecute {
509  stmt: "list_clients"
510  namespace: "xplugin"
511}
512-->expecterror 1820
513-->recvresult
514
515Mysqlx.Sql.StmtExecute {
516  stmt: "kill_client"
517  namespace: "xplugin"
518  args {
519    type: SCALAR
520    scalar {
521      type: V_UINT
522      v_unsigned_int: 8
523    }
524  }
525}
526-->recverror 1820
527
528-->echo expect error for status var executed with password expired user
529-->expecterror 1820
530-->sql
531show status like 'Mysqlx%client%';
532-->endsql
533
534EOF
535
536--write_file $MYSQL_TMP_DIR/admin_mixedcase.tmp
537-->echo checking list_clients and kill_client with mixed case, expect success as these commands are case insensitive
538Mysqlx.Sql.StmtExecute {
539  stmt: "LIST_clients"
540  namespace: "xplugin"
541}
542
543## expect Mysqlx.Sql.StmtExecuteOk
544-->recvresult client_id user host
545
546Mysqlx.Sql.StmtExecute {
547  stmt: "kill_CLIENT"
548  namespace: "xplugin"
549  args {
550    type: SCALAR
551    scalar {
552      type: V_UINT
553      v_unsigned_int: 998
554    }
555  }
556}
557-->recverror 1094
558
559-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=1 with root user when these commads executed with mixed case
560-->sql
561show status like 'Mysqlx%client%';
562-->endsql
563
564EOF
565
566###below script is blind, it can be modified more efficiently by reducing no of lines
567--write_file $MYSQL_TMP_DIR/admin_list_kill_100conns.tmp
568-->echo checking list_clients and kill_client with default 100 connections, expect success for both list and kill
569-->sql
570set @@global.mysqlx_max_connections=60;
571create user xconnection1@localhost identified by  'xconnection1';
572create user xconnection2@localhost identified by  'xconnection2';
573create user xconnection3@localhost identified by  'xconnection3';
574create user xconnection4@localhost identified by  'xconnection4';
575create user xconnection5@localhost identified by  'xconnection5';
576create user xconnection6@localhost identified by  'xconnection6';
577create user xconnection7@localhost identified by  'xconnection7';
578create user xconnection8@localhost identified by  'xconnection8';
579create user xconnection9@localhost identified by  'xconnection9';
580create user xconnection10@localhost identified by  'xconnection10';
581create user xconnection11@localhost identified by  'xconnection11';
582create user xconnection12@localhost identified by  'xconnection12';
583create user xconnection13@localhost identified by  'xconnection13';
584create user xconnection14@localhost identified by  'xconnection14';
585create user xconnection15@localhost identified by  'xconnection15';
586create user xconnection16@localhost identified by  'xconnection16';
587create user xconnection17@localhost identified by  'xconnection17';
588create user xconnection18@localhost identified by  'xconnection18';
589create user xconnection19@localhost identified by  'xconnection19';
590create user xconnection20@localhost identified by  'xconnection20';
591create user xconnection21@localhost identified by  'xconnection21';
592create user xconnection22@localhost identified by  'xconnection22';
593create user xconnection23@localhost identified by  'xconnection23';
594create user xconnection24@localhost identified by  'xconnection24';
595create user xconnection25@localhost identified by  'xconnection25';
596create user xconnection26@localhost identified by  'xconnection26';
597create user xconnection27@localhost identified by  'xconnection27';
598create user xconnection28@localhost identified by  'xconnection28';
599create user xconnection29@localhost identified by  'xconnection29';
600create user xconnection30@localhost identified by  'xconnection30';
601create user xconnection31@localhost identified by  'xconnection31';
602create user xconnection32@localhost identified by  'xconnection32';
603create user xconnection33@localhost identified by  'xconnection33';
604create user xconnection34@localhost identified by  'xconnection34';
605create user xconnection35@localhost identified by  'xconnection35';
606create user xconnection36@localhost identified by  'xconnection36';
607create user xconnection37@localhost identified by  'xconnection37';
608create user xconnection38@localhost identified by  'xconnection38';
609create user xconnection39@localhost identified by  'xconnection39';
610create user xconnection40@localhost identified by  'xconnection40';
611create user xconnection41@localhost identified by  'xconnection41';
612create user xconnection42@localhost identified by  'xconnection42';
613create user xconnection43@localhost identified by  'xconnection43';
614create user xconnection44@localhost identified by  'xconnection44';
615create user xconnection45@localhost identified by  'xconnection45';
616create user xconnection46@localhost identified by  'xconnection46';
617create user xconnection47@localhost identified by  'xconnection47';
618create user xconnection48@localhost identified by  'xconnection48';
619create user xconnection49@localhost identified by  'xconnection49';
620create user xconnection50@localhost identified by  'xconnection50';
621-->endsql
622-->echo Test data
623Mysqlx.Sql.StmtExecute {
624  stmt: "list_clients"
625  namespace: "xplugin"
626}
627
628-->echo expect Mysqlx.Sql.StmtExecuteOk
629-->recvresult
630
631-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0
632-->sql
633show status like 'Mysqlx%client%';
634-->endsql
635
636-->echo create and activate new session xconnection1
637-->newsession xconnection1	xconnection1	xconnection1
638-->newsession xconnection2	xconnection2	xconnection2
639-->newsession xconnection3	xconnection3	xconnection3
640-->newsession xconnection4	xconnection4	xconnection4
641-->newsession xconnection5	xconnection5	xconnection5
642-->newsession xconnection6	xconnection6	xconnection6
643-->newsession xconnection7	xconnection7	xconnection7
644-->newsession xconnection8	xconnection8	xconnection8
645-->newsession xconnection9	xconnection9	xconnection9
646-->newsession xconnection10	xconnection10	xconnection10
647-->newsession xconnection11	xconnection11	xconnection11
648-->newsession xconnection12	xconnection12	xconnection12
649-->newsession xconnection13	xconnection13	xconnection13
650-->newsession xconnection14	xconnection14	xconnection14
651-->newsession xconnection15	xconnection15	xconnection15
652-->newsession xconnection16	xconnection16	xconnection16
653-->newsession xconnection17	xconnection17	xconnection17
654-->newsession xconnection18	xconnection18	xconnection18
655-->newsession xconnection19	xconnection19	xconnection19
656-->newsession xconnection20	xconnection20	xconnection20
657-->newsession xconnection21	xconnection21	xconnection21
658-->newsession xconnection22	xconnection22	xconnection22
659-->newsession xconnection23	xconnection23	xconnection23
660-->newsession xconnection24	xconnection24	xconnection24
661-->newsession xconnection25	xconnection25	xconnection25
662-->newsession xconnection26	xconnection26	xconnection26
663-->newsession xconnection27	xconnection27	xconnection27
664-->newsession xconnection28	xconnection28	xconnection28
665-->newsession xconnection29	xconnection29	xconnection29
666-->newsession xconnection30	xconnection30	xconnection30
667-->newsession xconnection31	xconnection31	xconnection31
668-->newsession xconnection32	xconnection32	xconnection32
669-->newsession xconnection33	xconnection33	xconnection33
670-->newsession xconnection34	xconnection34	xconnection34
671-->newsession xconnection35	xconnection35	xconnection35
672-->newsession xconnection36	xconnection36	xconnection36
673-->newsession xconnection37	xconnection37	xconnection37
674-->newsession xconnection38	xconnection38	xconnection38
675-->newsession xconnection39	xconnection39	xconnection39
676-->newsession xconnection40	xconnection40	xconnection40
677-->newsession xconnection41	xconnection41	xconnection41
678-->newsession xconnection42	xconnection42	xconnection42
679-->newsession xconnection43	xconnection43	xconnection43
680-->newsession xconnection44	xconnection44	xconnection44
681-->newsession xconnection45	xconnection45	xconnection45
682-->newsession xconnection46	xconnection46	xconnection46
683-->newsession xconnection47	xconnection47	xconnection47
684-->newsession xconnection48	xconnection48	xconnection48
685-->newsession xconnection49	xconnection49	xconnection49
686-->newsession xconnection50	xconnection50	xconnection50
687
688Mysqlx.Sql.StmtExecute {
689  stmt: "list_clients"
690  namespace: "xplugin"
691}
692
693-->echo expect Mysqlx.Sql.StmtExecuteOk
694-->recvresult client_id user host
695
696## switch back to default session
697-->setsession
698
699-->echo list all connected clients
700Mysqlx.Sql.StmtExecute {
701  stmt: "list_clients"
702  namespace: "xplugin"
703}
704-->recvresult client_id user host
705
706-->sleep 1
707-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=0
708-->sql
709show status like 'Mysqlx%client%';
710show status like 'Mysqlx_sessions%'
711-->endsql
712
713-->echo killing all newly connected clients except root,one by one
714Mysqlx.Sql.StmtExecute {
715  stmt: "kill_client"
716  namespace: "xplugin"
717  args {
718    type: SCALAR
719    scalar {
720      type: V_UINT
721      v_unsigned_int: 11
722    }
723  }
724}
725
726-->recvresult
727Mysqlx.Sql.StmtExecute {
728  stmt: "kill_client"
729  namespace: "xplugin"
730  args {
731    type: SCALAR
732    scalar {
733      type: V_UINT
734      v_unsigned_int: 12
735    }
736  }
737}
738
739-->recvresult
740Mysqlx.Sql.StmtExecute {
741  stmt: "kill_client"
742  namespace: "xplugin"
743  args {
744    type: SCALAR
745    scalar {
746      type: V_UINT
747      v_unsigned_int: 13
748    }
749  }
750}
751
752-->recvresult
753Mysqlx.Sql.StmtExecute {
754  stmt: "kill_client"
755  namespace: "xplugin"
756  args {
757    type: SCALAR
758    scalar {
759      type: V_UINT
760      v_unsigned_int: 14
761    }
762  }
763}
764
765-->recvresult
766Mysqlx.Sql.StmtExecute {
767  stmt: "kill_client"
768  namespace: "xplugin"
769  args {
770    type: SCALAR
771    scalar {
772      type: V_UINT
773      v_unsigned_int: 15
774    }
775  }
776}
777
778-->recvresult
779Mysqlx.Sql.StmtExecute {
780  stmt: "kill_client"
781  namespace: "xplugin"
782  args {
783    type: SCALAR
784    scalar {
785      type: V_UINT
786      v_unsigned_int: 16
787    }
788  }
789}
790
791-->recvresult
792Mysqlx.Sql.StmtExecute {
793  stmt: "kill_client"
794  namespace: "xplugin"
795  args {
796    type: SCALAR
797    scalar {
798      type: V_UINT
799      v_unsigned_int: 17
800    }
801  }
802}
803
804-->recvresult
805Mysqlx.Sql.StmtExecute {
806  stmt: "kill_client"
807  namespace: "xplugin"
808  args {
809    type: SCALAR
810    scalar {
811      type: V_UINT
812      v_unsigned_int: 18
813    }
814  }
815}
816
817-->recvresult
818Mysqlx.Sql.StmtExecute {
819  stmt: "kill_client"
820  namespace: "xplugin"
821  args {
822    type: SCALAR
823    scalar {
824      type: V_UINT
825      v_unsigned_int: 19
826    }
827  }
828}
829
830-->recvresult
831Mysqlx.Sql.StmtExecute {
832  stmt: "kill_client"
833  namespace: "xplugin"
834  args {
835    type: SCALAR
836    scalar {
837      type: V_UINT
838      v_unsigned_int: 20
839    }
840  }
841}
842
843-->recvresult
844Mysqlx.Sql.StmtExecute {
845  stmt: "kill_client"
846  namespace: "xplugin"
847  args {
848    type: SCALAR
849    scalar {
850      type: V_UINT
851      v_unsigned_int: 21
852    }
853  }
854}
855
856-->recvresult
857Mysqlx.Sql.StmtExecute {
858  stmt: "kill_client"
859  namespace: "xplugin"
860  args {
861    type: SCALAR
862    scalar {
863      type: V_UINT
864      v_unsigned_int: 22
865    }
866  }
867}
868
869-->recvresult
870Mysqlx.Sql.StmtExecute {
871  stmt: "kill_client"
872  namespace: "xplugin"
873  args {
874    type: SCALAR
875    scalar {
876      type: V_UINT
877      v_unsigned_int: 23
878    }
879  }
880}
881
882-->recvresult
883Mysqlx.Sql.StmtExecute {
884  stmt: "kill_client"
885  namespace: "xplugin"
886  args {
887    type: SCALAR
888    scalar {
889      type: V_UINT
890      v_unsigned_int: 24
891    }
892  }
893}
894
895-->recvresult
896Mysqlx.Sql.StmtExecute {
897  stmt: "kill_client"
898  namespace: "xplugin"
899  args {
900    type: SCALAR
901    scalar {
902      type: V_UINT
903      v_unsigned_int: 25
904    }
905  }
906}
907
908-->recvresult
909Mysqlx.Sql.StmtExecute {
910  stmt: "kill_client"
911  namespace: "xplugin"
912  args {
913    type: SCALAR
914    scalar {
915      type: V_UINT
916      v_unsigned_int: 26
917    }
918  }
919}
920
921-->recvresult
922Mysqlx.Sql.StmtExecute {
923  stmt: "kill_client"
924  namespace: "xplugin"
925  args {
926    type: SCALAR
927    scalar {
928      type: V_UINT
929      v_unsigned_int: 27
930    }
931  }
932}
933
934-->recvresult
935Mysqlx.Sql.StmtExecute {
936  stmt: "kill_client"
937  namespace: "xplugin"
938  args {
939    type: SCALAR
940    scalar {
941      type: V_UINT
942      v_unsigned_int: 28
943    }
944  }
945}
946
947-->recvresult
948Mysqlx.Sql.StmtExecute {
949  stmt: "kill_client"
950  namespace: "xplugin"
951  args {
952    type: SCALAR
953    scalar {
954      type: V_UINT
955      v_unsigned_int: 29
956    }
957  }
958}
959
960-->recvresult
961Mysqlx.Sql.StmtExecute {
962  stmt: "kill_client"
963  namespace: "xplugin"
964  args {
965    type: SCALAR
966    scalar {
967      type: V_UINT
968      v_unsigned_int: 30
969    }
970  }
971}
972
973-->recvresult
974Mysqlx.Sql.StmtExecute {
975  stmt: "kill_client"
976  namespace: "xplugin"
977  args {
978    type: SCALAR
979    scalar {
980      type: V_UINT
981      v_unsigned_int: 31
982    }
983  }
984}
985
986-->recvresult
987Mysqlx.Sql.StmtExecute {
988  stmt: "kill_client"
989  namespace: "xplugin"
990  args {
991    type: SCALAR
992    scalar {
993      type: V_UINT
994      v_unsigned_int: 32
995    }
996  }
997}
998
999-->recvresult
1000Mysqlx.Sql.StmtExecute {
1001  stmt: "kill_client"
1002  namespace: "xplugin"
1003  args {
1004    type: SCALAR
1005    scalar {
1006      type: V_UINT
1007      v_unsigned_int: 33
1008    }
1009  }
1010}
1011
1012-->recvresult
1013Mysqlx.Sql.StmtExecute {
1014  stmt: "kill_client"
1015  namespace: "xplugin"
1016  args {
1017    type: SCALAR
1018    scalar {
1019      type: V_UINT
1020      v_unsigned_int: 34
1021    }
1022  }
1023}
1024
1025-->recvresult
1026Mysqlx.Sql.StmtExecute {
1027  stmt: "kill_client"
1028  namespace: "xplugin"
1029  args {
1030    type: SCALAR
1031    scalar {
1032      type: V_UINT
1033      v_unsigned_int: 35
1034    }
1035  }
1036}
1037
1038-->recvresult
1039Mysqlx.Sql.StmtExecute {
1040  stmt: "kill_client"
1041  namespace: "xplugin"
1042  args {
1043    type: SCALAR
1044    scalar {
1045      type: V_UINT
1046      v_unsigned_int: 36
1047    }
1048  }
1049}
1050
1051-->recvresult
1052Mysqlx.Sql.StmtExecute {
1053  stmt: "kill_client"
1054  namespace: "xplugin"
1055  args {
1056    type: SCALAR
1057    scalar {
1058      type: V_UINT
1059      v_unsigned_int: 37
1060    }
1061  }
1062}
1063
1064-->recvresult
1065Mysqlx.Sql.StmtExecute {
1066  stmt: "kill_client"
1067  namespace: "xplugin"
1068  args {
1069    type: SCALAR
1070    scalar {
1071      type: V_UINT
1072      v_unsigned_int: 38
1073    }
1074  }
1075}
1076
1077-->recvresult
1078Mysqlx.Sql.StmtExecute {
1079  stmt: "kill_client"
1080  namespace: "xplugin"
1081  args {
1082    type: SCALAR
1083    scalar {
1084      type: V_UINT
1085      v_unsigned_int: 39
1086    }
1087  }
1088}
1089
1090-->recvresult
1091Mysqlx.Sql.StmtExecute {
1092  stmt: "kill_client"
1093  namespace: "xplugin"
1094  args {
1095    type: SCALAR
1096    scalar {
1097      type: V_UINT
1098      v_unsigned_int: 40
1099    }
1100  }
1101}
1102
1103-->recvresult
1104Mysqlx.Sql.StmtExecute {
1105  stmt: "kill_client"
1106  namespace: "xplugin"
1107  args {
1108    type: SCALAR
1109    scalar {
1110      type: V_UINT
1111      v_unsigned_int: 41
1112    }
1113  }
1114}
1115
1116-->recvresult
1117Mysqlx.Sql.StmtExecute {
1118  stmt: "kill_client"
1119  namespace: "xplugin"
1120  args {
1121    type: SCALAR
1122    scalar {
1123      type: V_UINT
1124      v_unsigned_int: 42
1125    }
1126  }
1127}
1128
1129-->recvresult
1130Mysqlx.Sql.StmtExecute {
1131  stmt: "kill_client"
1132  namespace: "xplugin"
1133  args {
1134    type: SCALAR
1135    scalar {
1136      type: V_UINT
1137      v_unsigned_int: 43
1138    }
1139  }
1140}
1141
1142-->recvresult
1143Mysqlx.Sql.StmtExecute {
1144  stmt: "kill_client"
1145  namespace: "xplugin"
1146  args {
1147    type: SCALAR
1148    scalar {
1149      type: V_UINT
1150      v_unsigned_int: 44
1151    }
1152  }
1153}
1154
1155-->recvresult
1156Mysqlx.Sql.StmtExecute {
1157  stmt: "kill_client"
1158  namespace: "xplugin"
1159  args {
1160    type: SCALAR
1161    scalar {
1162      type: V_UINT
1163      v_unsigned_int: 45
1164    }
1165  }
1166}
1167
1168-->recvresult
1169Mysqlx.Sql.StmtExecute {
1170  stmt: "kill_client"
1171  namespace: "xplugin"
1172  args {
1173    type: SCALAR
1174    scalar {
1175      type: V_UINT
1176      v_unsigned_int: 46
1177    }
1178  }
1179}
1180
1181-->recvresult
1182Mysqlx.Sql.StmtExecute {
1183  stmt: "kill_client"
1184  namespace: "xplugin"
1185  args {
1186    type: SCALAR
1187    scalar {
1188      type: V_UINT
1189      v_unsigned_int: 47
1190    }
1191  }
1192}
1193
1194-->recvresult
1195Mysqlx.Sql.StmtExecute {
1196  stmt: "kill_client"
1197  namespace: "xplugin"
1198  args {
1199    type: SCALAR
1200    scalar {
1201      type: V_UINT
1202      v_unsigned_int: 48
1203    }
1204  }
1205}
1206
1207-->recvresult
1208Mysqlx.Sql.StmtExecute {
1209  stmt: "kill_client"
1210  namespace: "xplugin"
1211  args {
1212    type: SCALAR
1213    scalar {
1214      type: V_UINT
1215      v_unsigned_int: 49
1216    }
1217  }
1218}
1219
1220-->recvresult
1221Mysqlx.Sql.StmtExecute {
1222  stmt: "kill_client"
1223  namespace: "xplugin"
1224  args {
1225    type: SCALAR
1226    scalar {
1227      type: V_UINT
1228      v_unsigned_int: 50
1229    }
1230  }
1231}
1232
1233-->recvresult
1234Mysqlx.Sql.StmtExecute {
1235  stmt: "kill_client"
1236  namespace: "xplugin"
1237  args {
1238    type: SCALAR
1239    scalar {
1240      type: V_UINT
1241      v_unsigned_int: 51
1242    }
1243  }
1244}
1245
1246-->recvresult
1247Mysqlx.Sql.StmtExecute {
1248  stmt: "kill_client"
1249  namespace: "xplugin"
1250  args {
1251    type: SCALAR
1252    scalar {
1253      type: V_UINT
1254      v_unsigned_int: 52
1255    }
1256  }
1257}
1258
1259-->recvresult
1260Mysqlx.Sql.StmtExecute {
1261  stmt: "kill_client"
1262  namespace: "xplugin"
1263  args {
1264    type: SCALAR
1265    scalar {
1266      type: V_UINT
1267      v_unsigned_int: 53
1268    }
1269  }
1270}
1271
1272-->recvresult
1273Mysqlx.Sql.StmtExecute {
1274  stmt: "kill_client"
1275  namespace: "xplugin"
1276  args {
1277    type: SCALAR
1278    scalar {
1279      type: V_UINT
1280      v_unsigned_int: 54
1281    }
1282  }
1283}
1284
1285-->recvresult
1286Mysqlx.Sql.StmtExecute {
1287  stmt: "kill_client"
1288  namespace: "xplugin"
1289  args {
1290    type: SCALAR
1291    scalar {
1292      type: V_UINT
1293      v_unsigned_int: 55
1294    }
1295  }
1296}
1297
1298-->recvresult
1299Mysqlx.Sql.StmtExecute {
1300  stmt: "kill_client"
1301  namespace: "xplugin"
1302  args {
1303    type: SCALAR
1304    scalar {
1305      type: V_UINT
1306      v_unsigned_int: 56
1307    }
1308  }
1309}
1310
1311-->recvresult
1312Mysqlx.Sql.StmtExecute {
1313  stmt: "kill_client"
1314  namespace: "xplugin"
1315  args {
1316    type: SCALAR
1317    scalar {
1318      type: V_UINT
1319      v_unsigned_int: 57
1320    }
1321  }
1322}
1323
1324-->recvresult
1325Mysqlx.Sql.StmtExecute {
1326  stmt: "kill_client"
1327  namespace: "xplugin"
1328  args {
1329    type: SCALAR
1330    scalar {
1331      type: V_UINT
1332      v_unsigned_int: 58
1333    }
1334  }
1335}
1336
1337-->recvresult
1338Mysqlx.Sql.StmtExecute {
1339  stmt: "kill_client"
1340  namespace: "xplugin"
1341  args {
1342    type: SCALAR
1343    scalar {
1344      type: V_UINT
1345      v_unsigned_int: 59
1346    }
1347  }
1348}
1349
1350-->recvresult
1351Mysqlx.Sql.StmtExecute {
1352  stmt: "kill_client"
1353  namespace: "xplugin"
1354  args {
1355    type: SCALAR
1356    scalar {
1357      type: V_UINT
1358      v_unsigned_int: 60
1359    }
1360  }
1361}
1362
1363-->recvresult
1364
1365-->sql
1366select sleep(0.5);
1367-->endsql
1368
1369Mysqlx.Sql.StmtExecute {
1370  stmt: "list_clients"
1371  namespace: "xplugin"
1372}
1373
1374-->echo expect Mysqlx.Sql.StmtExecuteOk
1375-->recvresult client_id user host
1376
1377-->echo expect Mysqlx_stmt_list_clients=3 and Mysqlx_stmt_kill_client=49
1378-->sql
1379show status like 'Mysqlx%client%';
1380show status like 'Mysqlx_sessions%'
1381-->endsql
1382
1383-->sql
1384drop user xconnection1@localhost;
1385drop user xconnection2@localhost;
1386drop user xconnection3@localhost;
1387drop user xconnection4@localhost;
1388drop user xconnection5@localhost;
1389drop user xconnection6@localhost;
1390drop user xconnection7@localhost;
1391drop user xconnection8@localhost;
1392drop user xconnection9@localhost;
1393drop user xconnection10@localhost;
1394drop user xconnection11@localhost;
1395drop user xconnection12@localhost;
1396drop user xconnection13@localhost;
1397drop user xconnection14@localhost;
1398drop user xconnection15@localhost;
1399drop user xconnection16@localhost;
1400drop user xconnection17@localhost;
1401drop user xconnection18@localhost;
1402drop user xconnection19@localhost;
1403drop user xconnection20@localhost;
1404drop user xconnection21@localhost;
1405drop user xconnection22@localhost;
1406drop user xconnection23@localhost;
1407drop user xconnection24@localhost;
1408drop user xconnection25@localhost;
1409drop user xconnection26@localhost;
1410drop user xconnection27@localhost;
1411drop user xconnection28@localhost;
1412drop user xconnection29@localhost;
1413drop user xconnection30@localhost;
1414drop user xconnection31@localhost;
1415drop user xconnection32@localhost;
1416drop user xconnection33@localhost;
1417drop user xconnection34@localhost;
1418drop user xconnection35@localhost;
1419drop user xconnection36@localhost;
1420drop user xconnection37@localhost;
1421drop user xconnection38@localhost;
1422drop user xconnection39@localhost;
1423drop user xconnection40@localhost;
1424drop user xconnection41@localhost;
1425drop user xconnection42@localhost;
1426drop user xconnection43@localhost;
1427drop user xconnection44@localhost;
1428drop user xconnection45@localhost;
1429drop user xconnection46@localhost;
1430drop user xconnection47@localhost;
1431drop user xconnection48@localhost;
1432drop user xconnection49@localhost;
1433drop user xconnection50@localhost;
1434-->endsql
1435
1436EOF
1437
1438--write_file $MYSQL_TMP_DIR/admin_list_kill_sqlnamespace.tmp
1439-->echo execute list_clients,kill_client with sql namespace,expect error
1440-->echo change result file once error messages are fixed
1441Mysqlx.Sql.StmtExecute {
1442  stmt: "list_clients"
1443  namespace: "sql"
1444}
1445
1446-->echo expect Mysqlx.Sql.StmtExecuteOk
1447-->expecterror 1064
1448-->recvresult client_id user host
1449
1450Mysqlx.Sql.StmtExecute {
1451  stmt: "kill_client"
1452  namespace: "sql"
1453  args {
1454    type: SCALAR
1455    scalar {
1456      type: V_UINT
1457      v_unsigned_int: 11
1458    }
1459  }
1460}
1461
1462-->echo expect Mysqlx.Sql.StmtExecuteOk
1463-->expecterror 5015
1464-->recvresult
1465
1466Mysqlx.Sql.StmtExecute {
1467  stmt: "kill_client"
1468  namespace: ""
1469  args {
1470    type: SCALAR
1471    scalar {
1472      type: V_UINT
1473      v_unsigned_int: 11
1474    }
1475  }
1476}
1477
1478-->echo expect Mysqlx.Sql.StmtExecuteOk
1479-->expecterror 5162
1480-->recvresult
1481
1482Mysqlx.Sql.StmtExecute {
1483  stmt: "kill_client"
1484  namespace: "invalid"
1485  args {
1486    type: SCALAR
1487    scalar {
1488      type: V_UINT
1489      v_unsigned_int: 11
1490    }
1491  }
1492}
1493
1494-->echo expect Mysqlx.Sql.StmtExecuteOk
1495-->expecterror 5162
1496-->recvresult
1497
1498-->echo expect Mysqlx_stmt_list_clients=0 and Mysqlx_stmt_kill_client=0 as these are not executed on right namespace
1499-->sql
1500show status like 'Mysqlx%client%';
1501-->endsql
1502
1503EOF
1504
1505--write_file $MYSQL_TMP_DIR/admin_xkill_ssl.tmp
1506-->echo open xconnection with ssl and kill,expect success
1507-->sql
1508create user con1@localhost identified by 'con1';
1509create user con2@localhost identified by 'con2';
1510set @@global.mysqlx_max_connections=3;
1511-->endsql
1512-->echo Test data
1513Mysqlx.Sql.StmtExecute {
1514  stmt: "list_clients"
1515  namespace: "xplugin"
1516}
1517
1518-->echo expect Mysqlx.Sql.StmtExecuteOk
1519-->recvresult  client_id user host
1520
1521-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0
1522-->sql
1523show status like 'Mysqlx%client%';
1524-->endsql
1525
1526-->echo create and activate new session con1
1527-->newsession con1	con1	con1
1528
1529Mysqlx.Sql.StmtExecute {
1530  stmt: "list_clients"
1531  namespace: "xplugin"
1532}
1533
1534-->echo expect Mysqlx.Sql.StmtExecuteOk
1535-->recvresult  client_id user host
1536
1537-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0
1538-->sql
1539show status like 'Mysqlx%client%';
1540-->endsql
1541
1542-->echo open 3rd xprotocol connection where 2 sessions already opened
1543-->newsession con2	con2	con2
1544
1545-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0
1546-->sql
1547show status like 'Mysqlx%client%';
1548-->endsql
1549
1550## switch back to default session
1551-->setsession
1552
1553Mysqlx.Sql.StmtExecute {
1554  stmt: "list_clients"
1555  namespace: "xplugin"
1556}
1557
1558-->recvresult  client_id user host
1559
1560Mysqlx.Sql.StmtExecute {
1561  stmt: "kill_client"
1562  namespace: "xplugin"
1563  args {
1564    type: SCALAR
1565    scalar {
1566      type: V_UINT
1567      v_unsigned_int: 63
1568    }
1569  }
1570}
1571
1572-->echo expect Mysqlx.Sql.StmtExecuteOk
1573-->recvresult
1574
1575Mysqlx.Sql.StmtExecute {
1576  stmt: "kill_client"
1577  namespace: "xplugin"
1578  args {
1579    type: SCALAR
1580    scalar {
1581      type: V_UINT
1582      v_unsigned_int: 64
1583    }
1584  }
1585}
1586
1587-->echo expect Mysqlx.Sql.StmtExecuteOk
1588-->recvresult
1589
1590-->sql
1591select sleep(0.5);
1592-->endsql
1593
1594Mysqlx.Sql.StmtExecute {
1595  stmt: "list_clients"
1596  namespace: "xplugin"
1597}
1598
1599-->recvresult  client_id user host
1600
1601-->echo expect Mysqlx_stmt_list_clients=3 and Mysqlx_stmt_kill_client=2
1602-->sql
1603drop user con1@localhost;
1604drop user con2@localhost;
1605show status like 'Mysqlx%client%';
1606-->endsql
1607
1608EOF
1609
1610--write_file $MYSQL_TMP_DIR/admin_xkill_ssl_root.tmp
1611-->echo open xconnection with ssl root user kill,expect success
1612-->sql
1613create user con1@localhost identified by 'con1';
1614create user con2@localhost identified by 'con2';
1615set @@global.mysqlx_max_connections=3;
1616-->endsql
1617-->echo Test data
1618Mysqlx.Sql.StmtExecute {
1619  stmt: "list_clients"
1620  namespace: "xplugin"
1621}
1622
1623-->echo expect Mysqlx.Sql.StmtExecuteOk
1624-->recvresult  client_id user host
1625
1626-->echo create and activate new session con1
1627-->newsession con1      con1    con1
1628
1629Mysqlx.Sql.StmtExecute {
1630  stmt: "list_clients"
1631  namespace: "xplugin"
1632}
1633
1634-->echo expect Mysqlx.Sql.StmtExecuteOk
1635-->recvresult  client_id user host
1636
1637-->echo open 3rd xprotocol connection where 2 sessions already opened
1638-->newsession con2      con2    con2
1639
1640## switch back to default session
1641-->setsession
1642
1643Mysqlx.Sql.StmtExecute {
1644  stmt: "list_clients"
1645  namespace: "xplugin"
1646}
1647-->recvresult  client_id user host
1648
1649Mysqlx.Sql.StmtExecute {
1650  stmt: "kill_client"
1651  namespace: "xplugin"
1652  args {
1653    type: SCALAR
1654    scalar {
1655      type: V_UINT
1656      v_unsigned_int: 66
1657    }
1658  }
1659}
1660
1661-->echo expect Mysqlx.Sql.StmtExecuteOk
1662-->recvresult
1663
1664Mysqlx.Sql.StmtExecute {
1665  stmt: "kill_client"
1666  namespace: "xplugin"
1667  args {
1668    type: SCALAR
1669    scalar {
1670      type: V_UINT
1671      v_unsigned_int: 67
1672    }
1673  }
1674}
1675
1676-->echo expect Mysqlx.Sql.StmtExecuteOk
1677-->recvresult
1678
1679-->sql
1680select sleep(0.5);
1681-->endsql
1682
1683Mysqlx.Sql.StmtExecute {
1684  stmt: "list_clients"
1685  namespace: "xplugin"
1686}
1687
1688-->recvresult client_id user host
1689
1690-->sql
1691drop user con1@localhost;
1692drop user con2@localhost;
1693-->endsql
1694
1695EOF
1696
1697--write_file $MYSQL_TMP_DIR/admin_xkill_compatibility_56_OFF.tmp
1698-->sql
1699create user abc@localhost identified by 'abc';
1700create user xplugin@localhost identified by 'xplugin';
1701grant all on *.* to xplugin@localhost;
1702create user process@localhost identified by 'process';
1703grant process on *.* to process@localhost;
1704create user expire@localhost identified by 'expire';
1705grant all on *.* to expire@localhost;
1706alter user expire@localhost password expire;
1707-->endsql
1708-->echo Test data
1709Mysqlx.Sql.StmtExecute {
1710  stmt: "list_clients"
1711  namespace: "xplugin"
1712}
1713
1714-->echo expect Mysqlx.Sql.StmtExecuteOk
1715-->recvresult client_id user host
1716
1717-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0
1718-->sql
1719show status like 'Mysqlx%client%';
1720-->endsql
1721
1722-->echo create and activate new session
1723-->newsession aux	root
1724
1725Mysqlx.Sql.StmtExecute {
1726  stmt: "list_clients"
1727  namespace: "xplugin"
1728}
1729
1730-->echo expect Mysqlx.Sql.StmtExecuteOk
1731-->recvresult client_id user host
1732
1733-->echo expect Mysqlx_stmt_list_clients=1 and Mysqlx_stmt_kill_client=0 even with another new root session
1734-->sql
1735show status like 'Mysqlx%client%';
1736-->endsql
1737
1738-->echo switch back to default session
1739-->setsession
1740
1741Mysqlx.Sql.StmtExecute {
1742  stmt: "list_clients"
1743  namespace: "xplugin"
1744}
1745
1746-->echo expect error
1747-->recvresult client_id user host
1748
1749-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=0 with default root session where list_clients already executed
1750-->sql
1751show status like 'Mysqlx%client%';
1752-->endsql
1753
1754Mysqlx.Sql.StmtExecute {
1755  stmt: "kill_client"
1756  namespace: "xplugin"
1757  args {
1758    type: SCALAR
1759    scalar {
1760      type: V_UINT
1761      v_unsigned_int: 2
1762    }
1763  }
1764}
1765-->recvresult
1766
1767-->sql
1768select sleep(0.5);
1769-->endsql
1770
1771Mysqlx.Sql.StmtExecute {
1772  stmt: "list_clients"
1773  namespace: "xplugin"
1774}
1775#-->recverror 5162
1776-->recvresult client_id user host
1777
1778-->echo expect Mysqlx_stmt_list_clients=3 and Mysqlx_stmt_kill_client=1 with default root session where list_clients executed 3 times and kill_client once
1779-->sql
1780show status like 'Mysqlx%client%';
1781-->endsql
1782
1783-->echo create and activate new session abc
1784-->echo expect only abc user session id
1785-->newsession abc	abc	abc
1786
1787Mysqlx.Sql.StmtExecute {
1788  stmt: "list_clients"
1789  namespace: "xplugin"
1790}
1791
1792-->echo expect Mysqlx.Sql.StmtExecuteOk
1793-->recvresult client_id user host
1794
1795-->echo killing root user session with unprivileged user 'abc' which should be unsuccessful
1796Mysqlx.Sql.StmtExecute {
1797  stmt: "kill_client"
1798  namespace: "xplugin"
1799  args {
1800    type: SCALAR
1801    scalar {
1802      type: V_UINT
1803      v_unsigned_int: 1
1804    }
1805  }
1806}
1807
1808-->echo expect Mysqlx.Sql.StmtExecuteOk
1809-->expecterror 1095
1810-->recvresult
1811
1812-->echo expect ERROR: SELECT command denied to user 'abc'@'localhost' for table 'session_status' (code 1142) for show status command
1813-->sql
1814show status like 'Mysqlx%client%';
1815-->endsql
1816
1817-->echo open another session of abc user and kill first session of abc user,which should be successful
1818-->newsession abc1	abc	abc
1819
1820Mysqlx.Sql.StmtExecute {
1821  stmt: "list_clients"
1822  namespace: "xplugin"
1823}
1824
1825-->recvresult client_id user host
1826
1827Mysqlx.Sql.StmtExecute {
1828  stmt: "kill_client"
1829  namespace: "xplugin"
1830  args {
1831    type: SCALAR
1832    scalar {
1833      type: V_UINT
1834      v_unsigned_int: 3
1835    }
1836  }
1837}
1838
1839-->recvresult
1840
1841-->sql
1842select sleep(0.5);
1843-->endsql
1844
1845Mysqlx.Sql.StmtExecute {
1846  stmt: "list_clients"
1847  namespace: "xplugin"
1848}
1849
1850-->recvresult client_id user host
1851
1852-->echo expect ERROR: SELECT command denied to user 'abc'@'localhost' for table 'session_status' (code 1142) for show status command
1853-->sql
1854show status like 'Mysqlx%client%';
1855-->endsql
1856
1857-->echo killing abc user session with its own session 'abc' which should be successful
1858-->echo expect right error instead of End of File
1859Mysqlx.Sql.StmtExecute {
1860  stmt: "kill_client"
1861  namespace: "xplugin"
1862  args {
1863    type: SCALAR
1864    scalar {
1865      type: V_UINT
1866      v_unsigned_int: 4
1867    }
1868  }
1869}
1870
1871#-->echo expect Mysqlx.Sql.StmtExecuteOk
1872#-->recvresult
1873-->echo switch back to default session
1874-->recvuntildisc
1875
1876-->sleep 1
1877
1878Mysqlx.Sql.StmtExecute {
1879  stmt: "list_clients"
1880  namespace: "xplugin"
1881}
1882
1883-->echo expect Mysqlx.Sql.StmtExecuteOk
1884-->recvresult client_id user host
1885
1886-->echo expect Mysqlx_stmt_list_clients=4 and Mysqlx_stmt_kill_client=1 with default root session where list_clients executed 4 times and kill_client once
1887-->sql
1888show status like 'Mysqlx%client%';
1889-->endsql
1890
1891-->echo open process only privileged user seession and kill root user session,expect error "You are not owner of thread"
1892-->newsession process	process	process
1893Mysqlx.Sql.StmtExecute {
1894  stmt: "list_clients"
1895  namespace: "xplugin"
1896}
1897-->recvresult client_id user host
1898
1899Mysqlx.Sql.StmtExecute {
1900  stmt: "kill_client"
1901  namespace: "xplugin"
1902  args {
1903    type: SCALAR
1904    scalar {
1905      type: V_UINT
1906      v_unsigned_int: 1
1907    }
1908  }
1909}
1910
1911-->echo expect Mysqlx.Sql.StmtExecuteOk
1912-->expecterror 1095
1913-->recvresult
1914
1915-->sql
1916select sleep(0.5);
1917-->endsql
1918
1919-->echo checking list of clients after root user session killed by xplugin user
1920Mysqlx.Sql.StmtExecute {
1921  stmt: "list_clients"
1922  namespace: "xplugin"
1923}
1924
1925-->recvresult client_id user host
1926
1927-->echo expect ERROR: SELECT command denied to user 'process'@'localhost' for table 'session_status' (code 1142) for show command
1928-->sql
1929show status like 'Mysqlx%client%';
1930-->endsql
1931
1932-->echo open privileged user seession and kill root user session,expect success
1933-->newsession xplugin	xplugin	xplugin
1934
1935Mysqlx.Sql.StmtExecute {
1936  stmt: "list_clients"
1937  namespace: "xplugin"
1938}
1939
1940-->recvresult client_id user host
1941
1942Mysqlx.Sql.StmtExecute {
1943  stmt: "kill_client"
1944  namespace: "xplugin"
1945  args {
1946    type: SCALAR
1947    scalar {
1948      type: V_UINT
1949      v_unsigned_int: 1
1950    }
1951  }
1952}
1953
1954-->echo expect Mysqlx.Sql.StmtExecuteOk
1955-->recvresult
1956
1957-->sql
1958select sleep(0.5);
1959-->endsql
1960
1961-->echo checking list of clients after root user session killed by xplugin user
1962Mysqlx.Sql.StmtExecute {
1963  stmt: "list_clients"
1964  namespace: "xplugin"
1965}
1966
1967-->recvresult client_id user host
1968
1969-->echo expect Mysqlx_stmt_list_clients=2 and Mysqlx_stmt_kill_client=1 with xplugin user where list_clients executed 2 times and kill_client once
1970-->sql
1971show status like 'Mysqlx%client%';
1972-->endsql
1973
1974-->echo Cleanup
1975-->sql
1976drop schema if exists xtest;
1977-->endsql
1978
1979EOF
1980
1981--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/ /You are not owner of thread [0-9]+/You are not owner of thread/
1982--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/admin_xkill.tmp 2>&1
1983--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/
1984--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/admin_xkill_invaliddtype.tmp 2>&1
1985
1986##try executing list_clients and kill_client with password expired user, expect error
1987--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/ /Query/Execute/
1988--exec $MYSQLXTEST --connect-expired-password -uexpire --password='expire' --file=$MYSQL_TMP_DIR/admin_xkill_pwd_expire.tmp 2>&1
1989
1990##execute list_clients and kill_client with mixed case,expect command should be recognized
1991--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/
1992--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/admin_mixedcase.tmp 2>&1
1993
1994##open 100 xprotocol connections and list and kill them ony by one,expect success
1995--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/
1996--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/admin_list_kill_100conns.tmp 2>&1
1997
1998##execute list_clients,kill_client with invalid name space other than xplugin,exect unsuccess
1999--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/
2000--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/admin_list_kill_sqlnamespace.tmp 2>&1
2001
2002##verify list_clients and kill_client works with ssl privileged user
2003--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/
2004--exec $MYSQLXTEST -usslcon --password='sslcon' --ssl-key=$MYSQL_TEST_DIR/std_data/server-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/server-cert.pem --file=$MYSQL_TMP_DIR/admin_xkill_ssl.tmp 2>&1
2005
2006##verify list_clients and kill_client works with root user having ssl
2007--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/
2008--exec $MYSQLXTEST -uroot --password='' --ssl-key=$MYSQL_TEST_DIR/std_data/server-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/server-cert.pem --file=$MYSQL_TMP_DIR/admin_xkill_ssl_root.tmp 2>&1
2009##expect sum of all stats of kill_client,list_clients with native mysql clients as these are global to mysql client and local to mysqlx session
2010show status like 'Mysqlx%client%';
2011#show status like 'Mysqlx_sessions%';
2012
2013##verify Mysqlx_stmt_kill_client and Mysqlx_stmt_list_clients with show_compatibility_56=OFF which is default in 5.7
2014let $restart_parameters = restart: --show_compatibility_56=OFF;
2015--source ../include/restart_mysqld_and_wait_for_xplugin.inc
2016drop user abc@localhost;
2017drop user xplugin@localhost;
2018drop user process@localhost;
2019drop user expire@localhost;
2020###expects zero stats for kill_client,list_clients once server started first time
2021set @@global.mysqlx_max_connections=100;
2022show status like 'Mysqlx%client%';
2023select sleep(0.5);
2024--replace_regex /([a-z0-9]+	localhost	)[0-9]+/\1$SESSION/ /You are not owner of thread [0-9]+/You are not owner of thread/
2025--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/admin_xkill_compatibility_56_OFF.tmp 2>&1
2026##expect sum of all stats of kill_client,list_clients with native mysql clients as these are global to mysql client and local to mysqlx session
2027##seems to be it is not working that way
2028show status like 'Mysqlx%client%';
2029--remove_file $MYSQL_TMP_DIR/admin_xkill.tmp
2030--remove_file $MYSQL_TMP_DIR/admin_xkill_ssl.tmp
2031--remove_file $MYSQL_TMP_DIR/admin_xkill_ssl_root.tmp
2032--remove_file $MYSQL_TMP_DIR/admin_xkill_invaliddtype.tmp
2033--remove_file $MYSQL_TMP_DIR/admin_xkill_pwd_expire.tmp
2034--remove_file $MYSQL_TMP_DIR/admin_mixedcase.tmp
2035--remove_file $MYSQL_TMP_DIR/admin_list_kill_100conns.tmp
2036--remove_file $MYSQL_TMP_DIR/admin_list_kill_sqlnamespace.tmp
2037--remove_file $MYSQL_TMP_DIR/admin_xkill_compatibility_56_OFF.tmp
2038
2039## Postamble
2040uninstall plugin mysqlx;
2041drop user abc@localhost;
2042drop user xplugin@localhost;
2043drop user process@localhost;
2044drop user expire@localhost;
2045drop user sslcon@localhost;
2046