Debian Codegraph @

mysql-test/suite/x/t/stmtexecute_status_vars.test

raw
1 ## ===================================================================
2 ###
3 ### Monitor CRUD Status variables :
4 # 1) Mysqlx_stmt_execute_sql
5 # 2) Mysqlx_stmt_execute_mysqlx
6 # 3) Mysqlx_stmt_create_collection
7 # 4) Mysqlx_stmt_create_collection_index
8 # 5) Mysqlx_rows_sent
9 # 6) Mysqlx_bytes_sent
10 # 7) Mysqlx_bytes_received
11 # 8) Mysqlx_stmt_drop_collection
12 # 9) Mysqlx_stmt_drop_collection_index
13 # 10) Mysqlx_stmt_ping
14 # 11) Mysqlx_expect_close
15 # 12) Mysqlx_expect_open
16 # 13) Mysqlx_stmt_list_objects
17 #
18 ###
19 ### ===================================================================
20
21
22
23 #
24 # 1) Mysqlx_stmt_execute_sql
25 # 2) Mysqlx_stmt_execute_mysqlx
26 # 13) Mysqlx_stmt_list_objects
27 #
28 ## Preamble
29 --source include/xplugin_preamble.inc
30 --source include/xplugin_create_user.inc
31
32 --disable_query_log
33 --disable_warnings
34 DROP DATABASE IF EXISTS xplugintest;
35 DROP DATABASE IF EXISTS xplugintest_1;
36 CREATE DATABASE xplugintest;
37 CREATE DATABASE xplugintest_1;
38 USE xplugintest;
39 --enable_warnings
40 --enable_query_log
41
42 CREATE TABLE `scalar_types`(`number_uint` INTEGER UNSIGNED DEFAULT 10, `number_sint` INTEGER DEFAULT -10, `value_bool` BOOLEAN DEFAULT 0, `value_string` VARCHAR(255) default NULL, `number_float` FLOAT DEFAULT 1.1, `number_double` DOUBLE DEFAULT 2.2, `value_blob` TINYBLOB DEFAULT NULL);
43
44
45 --write_file $MYSQL_TMP_DIR/stmtexecute_insert.xpl
46
47 -->sql
48 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
49 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
50 -->endsql
51
52 #-- "Create table table2 in xplugintest "
53 -->stmtadmin create_collection {"schema":"xplugintest","name":"table2"}
54 -->recvresult
55
56
57
58 Mysqlx.Sql.StmtExecute {
59 stmt: "INSERT INTO `xplugintest`.`scalar_types`(`number_sint`, `number_uint`, `value_string`) VALUES(0, ?, 'First inserted row'),(?, 1,'Second inserted row'), (-1, 0,?)"
60 args {
61 type: SCALAR
62 scalar {
63 type: V_UINT
64 v_unsigned_int: 1
65 }
66 }
67 args {
68 type: SCALAR
69 scalar {
70 type: V_SINT
71 v_signed_int: -1
72 }
73 }
74 args {
75 type: SCALAR
76 scalar {
77 type: V_STRING
78 v_string {
79 value: "\"Thrid\" inserted 'row'"
80 }
81 }
82 }
83 }
84 -->recvresult
85
86 Mysqlx.Sql.StmtExecute {
87 stmt: "INSERT INTO `xplugintest`.`scalar_types`(`number_float`, `number_double`, `value_blob`) VALUES(0.1, ?, 'First inserted blob'),(?, 200.01,'Second inserted blob'), (10.11, 2.2, ?), (111, 222, ?)"
88 args {
89 type: SCALAR
90 scalar {
91 type: V_DOUBLE
92 v_double: 200.01
93 }
94 }
95 args {
96 type: SCALAR
97 scalar {
98 type: V_DOUBLE
99 v_double: 10.11
100 }
101 }
102 args {
103 type: SCALAR
104 scalar {
105 type: V_STRING
106 v_string {
107 value: "\"Thrid\" inserted 'blob'"
108 }
109 }
110 }
111 args {
112 type: SCALAR
113 scalar {
114 type: V_NULL
115 }
116 }
117 }
118 -->recvresult
119 -->sql
120 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
121 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
122 -->endsql
123 EOF
124
125
126
127 --write_file $MYSQL_TMP_DIR/stmtexecute_select.xpl
128 -->sql
129 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
130 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
131 -->endsql
132 -->echo Filter data by unsigned int
133 Mysqlx.Sql.StmtExecute {
134 stmt: "SELECT * FROM `xplugintest`.`scalar_types` WHERE `number_uint`=?"
135 args {
136 type: SCALAR
137 scalar {
138 type: V_UINT
139 v_unsigned_int: 1
140 }
141 }
142 }
143 -->recvresult
144
145 -->echo Filter data by signed int
146 Mysqlx.Sql.StmtExecute {
147 stmt: "SELECT * FROM `xplugintest`.`scalar_types` WHERE `number_sint`=?"
148 args {
149 type: SCALAR
150 scalar {
151 type: V_SINT
152 v_signed_int: -1
153 }
154 }
155 }
156 -->recvresult
157
158 -->sql
159 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
160 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
161 -->endsql
162
163 EOF
164
165 ## New session will not show values from other session
166 --exec $MYSQLXTEST -ux_root --password='' --mysql41-auth --file=$MYSQL_TMP_DIR/stmtexecute_insert.xpl 2>&1
167 --remove_file $MYSQL_TMP_DIR/stmtexecute_insert.xpl
168
169 --write_file $MYSQL_TMP_DIR/stmtexecute_second_client.xpl
170 -->sql
171 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
172 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
173 -->endsql
174 EOF
175 --exec $MYSQLXTEST -ux_root --password='' --mysql41-auth --file=$MYSQL_TMP_DIR/stmtexecute_second_client.xpl 2>&1
176 --remove_file $MYSQL_TMP_DIR/stmtexecute_second_client.xpl
177
178
179 SELECT * FROM `xplugintest`.`scalar_types`;
180
181
182 # Run command
183 --exec $MYSQLXTEST -ux_root --password='' --mysql41-auth --file=$MYSQL_TMP_DIR/stmtexecute_select.xpl 2>&1
184 --remove_file $MYSQL_TMP_DIR/stmtexecute_select.xpl
185
186
187 --write_file $MYSQL_TMP_DIR/stmtexecute_insert.xpl
188 -->sql
189 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
190 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
191 -->endsql
192 -->echo Insert multiple rows into a Document column
193 Mysqlx.Crud.Insert {
194 collection {
195 name: "table2"
196 schema: "xplugintest"
197 }
198 data_model: DOCUMENT
199 row {
200 field {
201 type: LITERAL
202 literal {
203 type: V_STRING
204 v_string {
205 value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Bras\", \"id\": \"1\"\n}"
206 }
207 }
208 }}
209 row {
210 field {
211 type: LITERAL
212 literal {
213 type: V_STRING
214 v_string {
215 value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Mex\", \"id\": \"2\"\n}"
216 }
217 }}
218 }
219 }
220 -->recvresult
221 Mysqlx.Crud.Insert {
222 collection {
223 name: "table2"
224 schema: "xplugintest"
225 }
226 data_model: DOCUMENT
227 row {
228 field {
229 type: LITERAL
230 literal {
231 type: V_STRING
232 v_string {
233 value: "\n{\n \"_id\": \"3\",\n \"name\": \"Omar Peru\", \"id\": \"3\"\n}"
234 }
235 }
236 }}
237 }
238 -->recvresult
239
240 -->stmtadmin list_objects {"schema":"xplugintest"}
241 -->recvresult
242 #-- statement retunin error counted as well
243 -->stmtadmin list_objects {"schema":"nodatabase"}
244
245 #-- Invalid Mysqlx.Sql.StmtExecute operation conted
246 Mysqlx.Sql.StmtExecute {
247 stmt: "errorstatement"
248 args {
249 type: SCALAR
250 scalar {
251 type: V_STRING
252 v_string {
253 value: "nodatabase"
254 }
255 }
256 }
257 namespace: "mysqlx"
258 }
259 -->expecterror 1049
260 -->recvresult
261 -->expecterror 5157
262 -->recvresult
263
264
265
266
267 -->sql
268 SHOW STATUS like 'Mysqlx_stmt_execute_sql%';
269 #-- "Insert not counted in Mysqlx_stmt_execute_mysqlx"
270 SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx%';
271 #-- "Insert counted in Mysqlx_crud_insert"
272 SHOW STATUS like 'Mysqlx_crud_insert%';
273 SHOW STATUS like 'Mysqlx_stmt_list_objects%';
274 -->endsql
275 EOF
276
277 --exec $MYSQLXTEST -ux_root --password='' --mysql41-auth --file=$MYSQL_TMP_DIR/stmtexecute_insert.xpl 2>&1
278 --remove_file $MYSQL_TMP_DIR/stmtexecute_insert.xpl
279
280
281 ## Cleanup
282 DROP DATABASE xplugintest;
283 DROP DATABASE xplugintest_1;
284
285 #-----------------------------------------------------------------------------
286 # Test more variable on clean data
287
288 # 3) Mysqlx_stmt_create_collection
289 # 4) Mysqlx_stmt_create_collection_index
290 # 5) Mysqlx_rows_sent
291 # 6) Mysqlx_bytes_sent
292 # 7) Mysqlx_bytes_received
293 # 8) Mysqlx_stmt_drop_collection
294 # 9) Mysqlx_stmt_drop_collection_index
295 # 10) Mysqlx_stmt_ping
296 # 11) Mysqlx_expect_close
297 # 12) Mysqlx_expect_open
298 #-----------------------------------------------------------------------------
299
300 --disable_query_log
301 --disable_warnings
302 DROP DATABASE IF EXISTS xplugintest;
303 DROP DATABASE IF EXISTS xplugintest_1;
304 CREATE DATABASE xplugintest;
305 CREATE DATABASE xplugintest_1;
306 USE xplugintest;
307 --enable_warnings
308 --enable_query_log
309
310 CREATE TABLE `scalar_types`(`number_uint` INTEGER UNSIGNED DEFAULT 10, `number_sint` INTEGER DEFAULT -10, `value_bool` BOOLEAN DEFAULT 0, `value_string` VARCHAR(255) default NULL, `number_float` FLOAT DEFAULT 1.1, `number_double` DOUBLE DEFAULT 2.2, `value_blob` TINYBLOB DEFAULT NULL);
311
312
313 --write_file $MYSQL_TMP_DIR/stmtexecute_insert.xpl
314
315 SHOW STATUS like 'Mysqlx_stmt_create_collection';
316 SHOW STATUS like 'Mysqlx_stmt_create_collection_index%';
317 SHOW STATUS like 'Mysqlx_rows_sent%';
318 SHOW STATUS like 'Mysqlx_bytes_sent';
319
320 #-- "Create table table2 in xplugintest "
321 -->stmtadmin create_collection {"schema":"xplugintest","name":"table2"}
322 -->recvresult
323
324 -->echo Command is valid but returns error so its counted in status variable
325 -->stmtadmin create_collection {"schema":"xplugintest","name":""}
326 -->expecterror 5113
327 -->recvresult
328
329 -->echo Parse error , so its not counted in status variable
330 Mysqlx.Sql.StmtExecute {
331 stmt: "create_collection"
332 }
333 -->recv
334
335 -->echo "Index with unique(true), index column NOT NULL (true)" counted in index status variable
336 -->stmtadmin create_collection_index {"schema":"xplugintest", "collection":"table2", "name":"col1_index", "unique":true, "fields":{"field":"$.col1", "type":"TEXT(13)","required":true}}
337 -->recv
338
339 -->echo Command is parsed , returns error. Counted in status variable
340 -->stmtadmin create_collection_index {"schema":"xplugintest", "collection":"table_non_existing", "name":"col1_index", "unique":true, "fields":{"field":"$.col1", "type":"TEXT(13)","required":true}}
341 -->recv
342
343
344 -->echo Invalid index command. Not able to parse so not counted in status variable
345 Mysqlx.Sql.StmtExecute {
346 stmt: "create_collection_index"
347 }
348 -->recv
349
350 -->echo "Create table table3 in xplugintest "
351 -->stmtadmin create_collection {"schema":"xplugintest","name":"table3"}
352 -->recvresult
353
354
355 Mysqlx.Sql.StmtExecute {
356 stmt: "INSERT INTO `xplugintest`.`scalar_types`(`number_sint`, `number_uint`, `value_string`) VALUES(0, ?, 'First inserted row'),(?, 1,'Second inserted row'), (-1, 0,?)"
357 args {
358 type: SCALAR
359 scalar {
360 type: V_UINT
361 v_unsigned_int: 1
362 }
363 }
364 args {
365 type: SCALAR
366 scalar {
367 type: V_SINT
368 v_signed_int: -1
369 }
370 }
371 args {
372 type: SCALAR
373 scalar {
374 type: V_STRING
375 v_string {
376 value: "\"Thrid\" inserted 'row'"
377 }
378 }
379 }
380 }
381 -->recvresult
382
383 Mysqlx.Sql.StmtExecute {
384 stmt: "INSERT INTO `xplugintest`.`scalar_types`(`number_float`, `number_double`, `value_blob`) VALUES(0.1, ?, 'First inserted blob'),(?, 200.01,'Second inserted blob'), (10.11, 2.2, ?), (111, 222, ?)"
385 args {
386 type: SCALAR
387 scalar {
388 type: V_DOUBLE
389 v_double: 200.01
390 }
391 }
392 args {
393 type: SCALAR
394 scalar {
395 type: V_DOUBLE
396 v_double: 10.11
397 }
398 }
399 args {
400 type: SCALAR
401 scalar {
402 type: V_STRING
403 v_string {
404 value: "\"Thrid\" inserted 'blob'"
405 }
406 }
407 }
408 args {
409 type: SCALAR
410 scalar {
411 type: V_NULL
412 }
413 }
414 }
415 -->recvresult
416
417 USE xplugintest;
418 SHOW STATUS like 'Mysqlx_stmt_create_collection';
419
420 # Create SQL not counted in Mysqlx_stmt_create_collection
421 CREATE TABLE `table4` (`number_uint` INTEGER UNSIGNED DEFAULT 10, `number_sint` INTEGER DEFAULT -10, `value_bool` BOOLEAN DEFAULT 0, `value_string` VARCHAR(255) default NULL, `number_float` FLOAT DEFAULT 1.1, `number_double` DOUBLE DEFAULT 2.2, `value_blob` TINYBLOB DEFAULT NULL);
422 # Create index not counted Mysqlx_stmt_create_collection_index
423 ALTER TABLE xplugintest.table4 ADD FULLTEXT INDEX `fulltext_idx_1` (value_string);
424
425 SHOW STATUS like 'Mysqlx_stmt_create_collection';
426 SHOW STATUS like 'Mysqlx_stmt_create_collection_index%';
427 SHOW STATUS like 'Mysqlx_rows_sent%';
428 SHOW STATUS like 'Mysqlx_bytes_sent';
429
430 -->echo Filter data by unsigned int
431 Mysqlx.Sql.StmtExecute {
432 stmt: "SELECT * FROM `xplugintest`.`scalar_types` WHERE `number_uint`=?"
433 args {
434 type: SCALAR
435 scalar {
436 type: V_UINT
437 v_unsigned_int: 1
438 }
439 }
440 }
441 -->recvresult
442
443 -->echo Filter data by signed int
444 Mysqlx.Sql.StmtExecute {
445 stmt: "SELECT * FROM `xplugintest`.`scalar_types` WHERE `number_sint`=?"
446 args {
447 type: SCALAR
448 scalar {
449 type: V_SINT
450 v_signed_int: -1
451 }
452 }
453 }
454 -->recvresult
455
456
457 SHOW STATUS like 'Mysqlx_stmt_create_collection';
458 SHOW STATUS like 'Mysqlx_stmt_create_collection_index%';
459 SHOW STATUS like 'Mysqlx_rows_sent%';
460 SHOW STATUS like 'Mysqlx_bytes_sent';
461
462 SHOW STATUS like 'Mysqlx_stmt_drop_collection';
463 SHOW STATUS like 'Mysqlx_stmt_drop_collection_index%';
464 SHOW STATUS like 'Mysqlx_stmt_ping%';
465
466 -->echo # drop index counted in status variable
467 -->stmtadmin drop_collection_index {"schema":"xplugintest", "collection":"table2", "name":"col1_index"}
468 -->recv
469
470
471 -->echo "drop index with error counted in status variable"
472 -->stmtadmin drop_collection_index {"schema":"xplugintest", "collection":"table2", "name":"non_existing_index"}
473 -->recv
474
475
476 -->echo "Parse error not counted in status variable"
477 Mysqlx.Sql.StmtExecute {
478 stmt: "drop_collection_index"
479 }
480 -->recv
481
482 -->echo # drop collection , index sql not counted in status variable
483 -->sql
484 DROP TABLE xplugintest.table3;
485 ALTER TABLE xplugintest.table4 DROP INDEX `fulltext_idx_1`;
486 -->endsql
487
488 -->echo "Drop table created using create_collection message"
489 -->stmtadmin drop_collection {"schema":"xplugintest","name":"table2"}
490 -->recvresult
491
492 -->echo "Non existing Drop table counted in status variable"
493 -->stmtadmin drop_collection {"schema":"xplugintest","name":"table_non_existing"}
494 -->expecterror 1051
495 -->recvresult
496
497
498 -->echo "Drop table parse error NOT counted in status variable"
499 Mysqlx.Sql.StmtExecute {
500 stmt: "drop_collection"
501 }
502 -->recv
503
504 -->echo "Drop table created using create_collection message"
505 -->stmtadmin drop_collection {"schema":"xplugintest","name":"scalar_types"}
506 -->recvresult
507
508
509
510 -->sql
511 SHOW STATUS like 'Mysqlx_stmt_drop_collection';
512 SHOW STATUS like 'Mysqlx_stmt_drop_collection_index%';
513 -->endsql
514
515 -->stmtadmin ping
516 -->recv
517
518 Mysqlx.Sql.StmtExecute {
519 namespace : "bla"
520 stmt : "ping"
521 }
522 # error
523 -->recv
524
525 -->stmtadmin ping
526 -->recv
527
528 -->sql
529 SHOW STATUS like 'Mysqlx_stmt_ping%';
530 -->endsql
531
532 -->echo Check - expect.open and expect.close status variable
533 -->sql
534 SHOW STATUS like 'Mysqlx_expect_close%';
535 SHOW STATUS like 'Mysqlx_expect_open%';
536 -->endsql
537 Mysqlx.Expect.Open {
538 cond {
539 condition_key: 1
540 }
541 }
542 -->recv
543 Mysqlx.Expect.Open {
544 }
545 -->recv
546 -->sql
547 SHOW STATUS like 'Mysqlx_expect_close%';
548 SHOW STATUS like 'Mysqlx_expect_open%';
549 -->endsql
550 Mysqlx.Expect.Close {
551 }
552 -->recv
553 -->sql
554 SHOW STATUS like 'Mysqlx_expect_close%';
555 SHOW STATUS like 'Mysqlx_expect_open%';
556 -->endsql
557 Mysqlx.Expect.Close {
558 }
559 -->recv
560 -->sql
561 SHOW STATUS like 'Mysqlx_expect_close%';
562 SHOW STATUS like 'Mysqlx_expect_open%';
563 -->endsql
564
565 EOF
566
567 ## Test starts here
568 --exec $MYSQLXTEST -ux_root --password='' --mysql41-auth --file=$MYSQL_TMP_DIR/stmtexecute_insert.xpl 2>&1
569
570 ## Cleanup
571 DROP DATABASE xplugintest;
572 DROP DATABASE xplugintest_1;
573 --source ../include/xplugin_cleanup.inc