Debian Codegraph @

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

raw
1 ##
2 ## There are three levels on which the feature is verified:
3 ##
4 ## * on X Protocol layer (without decompression)
5 ## * confirming that resultset flow is correct
6 ## * confirming that resultset contains correct data
7 ##
8 ## Test that verifies generation of `Mysqlx.Connection.Compression` message that
9 ## encapsulates exactly one X Protocol messages.
10 ## The resultset is verified without decompression (bullet point 1).
11 ##
12 #
13 # This tests doesn't verifies the content of compressed messages, its done in other tests like:
14 # * flow_compression_resultset_*.test
15 #
16
17 ##
18 ## Please take a note that this test (and others) use following terms:
19 ## SINGLE, MULTIPLE, GROUP
20 ##
21 ## Those correspond to concrete setting of compression capabilities:
22 ## server_combine_mixed_messages, server_max_combine_messages and
23 ## describe only compressed messages generated by the server.
24 ##
25 ## * SINGLE - it corresponds to
26 ## server_combine_mixed_messages=TRUE|FALSE,
27 ## server_max_combine_messages=1
28 ## In this configuration exact one X Protocol message is
29 ## encapsulated in one Mysqlx.Connection.Compression
30 ##
31 ## * MULTIPLE - it corresponds to
32 ## server_combine_mixed_messages=FALSE,
33 ## server_max_combine_messages=UNSET|0
34 ## In this configuration multiple X Protocol messages
35 ## of the same type are encapsulated in one
36 ## Mysqlx.Connection.Compression
37 ##
38 ## * GROUP - it corresponds to
39 ## server_combine_mixed_messages=TRUE,
40 ## server_max_combine_messages=UNSET|0
41 ## In this configuration multiple X Protocol messages
42 ## of different types are encapsulated in one
43 ## Mysqlx.Connection.Compression
44 ##
45 ## Cases where "server_max_combine_message" has values grater than 1
46 ## are in separate test file: compression_limit_message_count.test
47 ##
48
49 ## Preamble
50 --source include/xplugin_preamble.inc
51 --source include/xplugin_create_user.inc
52 ## Test starts here
53
54 --write_file $MYSQL_TMP_DIR/resultset.xpl
55 -->import assert_messages.macro
56 -->import assert_notices.macro
57 -->import crud_insert.macro
58
59 -->echo
60 -->echo
61 -->echo ## Test setup
62
63 ##
64 ## Execution of SQL through X Protocol can generate flow
65 ## described by following UML flow (GRAPH 1):
66 ##
67 ## ...
68 ## loop has more resultsets or not at end of fetch
69 ## group resultset
70 ## loop has more columns
71 ## server --> client: ColumnMetaData
72 ## end
73 ## loop has more rows
74 ## server --> client: Row
75 ## end
76 ## end
77 ## alt has more resultsets
78 ## server --> client: FetchDoneMoreResultsets
79 ## end
80 ## end
81 ## loop has more OUT-paramsets or not at end of fetch
82 ## server --> client: FetchDoneMoreOutParams
83 ## group resultset
84 ## loop has more columns
85 ## server --> client: ColumnMetaData
86 ## end
87 ## loop has more rows
88 ## server --> client: Row
89 ## end
90 ## end
91 ## end
92 ## alt at end of all resultsets
93 ## server --> client: FetchDone
94 ## else cursor is opened
95 ## server --> client: FetchSuspended
96 ## end
97 ## ...
98 ##
99 ## After compression is enabled the flows stays the same, still
100 ## each message is wrapped inside `Mysqlx.Connection.Compression` message.
101 ## Thus on message-frame level its going to look in following way (GRAPH 2):
102 ##
103 ## ...
104 ## loop has more resultsets or not at end of fetch
105 ## group resultset
106 ## loop has more columns
107 ## server --> client: Compression(ColumnMetaData)
108 ## end
109 ## loop has more rows
110 ## server --> client: Compression(Row)
111 ## end
112 ## end
113 ## alt has more resultsets
114 ## server --> client: Compression(FetchDoneMoreResultsets)
115 ## end
116 ## end
117 ## loop has more OUT-paramsets or not at end of fetch
118 ## server --> client: Compression(FetchDoneMoreOutParams)
119 ## group resultset
120 ## loop has more columns
121 ## server --> client: Compression(ColumnMetaData)
122 ## end
123 ## loop has more rows
124 ## server --> client: Compression(Row)
125 ## end
126 ## end
127 ## end
128 ## alt at end of all resultsets
129 ## server --> client: Compression(FetchDone)
130 ## else cursor is opened
131 ## server --> client: Compression(FetchSuspended)
132 ## end
133 ## ...
134
135 ## Test case description:
136 -->echo
137 -->echo
138 -->echo ## I. Validate that X Plugin sends compressed messages in StmtExecute resultset (GRAPH 2)
139 -->echo #
140 -->echo # 1. Assert SELECTs empty resultset
141 -->echo # 2. Assert SELECTs resultset with one column and one row
142 -->echo # 3. Assert SELECTs resultset with one column and multiple rows
143 -->echo # 4. Assert SELECTs resultset with multiple columns and multiple rows
144 -->echo # 5. Assert SQL that returns multiple resultsets
145 -->echo #
146 -->echo ## II. Validate that X Plugin sends compressed messages in Crud.Insert resultset (GRAPH 2)
147 -->echo #
148 -->echo # 1. Assert Crud.Insert resultset for single row insert
149 -->echo # 2. Assert Crud.Insert resultset for multiple rows insert
150 -->echo #
151 -->echo ## III. Validate that X Plugin sends compressed messages in Crud.Find resultset (GRAPH 2)
152 -->echo #
153 -->echo # 1. Assert Crud.Find empty resultset
154 -->echo # 2. Assert Crud.Find resultset with multiple rows
155 -->echo #
156 -->echo ## IV. Validate that X Plugin sends compressed messages in Crud.Update resultset (GRAPH 2)
157 -->echo #
158 -->echo # 1. Assert Crud.Update resultset with no hits
159 -->echo # 2. Assert Crud.Update resultset with multiple updated rows
160 -->echo #
161 -->echo ## V. Validate that X Plugin sends compressed messages in Crud.Delete resultset (GRAPH 2)
162 -->echo #
163 -->echo # 1. Assert Crud.Delete resultset with no hits
164 -->echo # 2. Assert Crud.Delete resultset with multiple deleted rows
165 -->echo #
166 -->echo ## VI. Validate that X Plugin sends compressed messages in PrepStmt resultset (GRAPH 2)
167 -->echo #
168 -->echo # 1. Assert PrepStmt resultset with out-params
169 -->echo # 2. Assert Cursor resultset that was suspended
170 -->echo
171
172 -->import sample_tables.macro
173 -->callmacro Create_table_xtbl_with_phrase_and_prio
174 -->callmacro Create_collection_coll_with_phrase_and_prio
175
176 -->echo
177 -->echo #
178 -->echo # I.1
179 stmtsql SELECT phrase FROM xtbl WHERE prio < 0;
180 # Compressed ColumnMetadata
181 callmacro Assert_frame COMPRESSION;
182 # Compressed Notice
183 callmacro Assert_frame COMPRESSION;
184 # Compressed FetchDone
185 callmacro Assert_frame COMPRESSION;
186 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
187
188
189 -->echo
190 -->echo #
191 -->echo # I.2
192 stmtsql SELECT phrase FROM xtbl LIMIT 1;
193 # Compressed ColumnMetadata
194 callmacro Assert_frame COMPRESSION;
195 # Compressed Row
196 callmacro Assert_frame COMPRESSION;
197 # Compressed Notice
198 callmacro Assert_frame COMPRESSION;
199 # Compressed FetchDone
200 callmacro Assert_frame COMPRESSION;
201 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
202
203
204 -->echo
205 -->echo #
206 -->echo # I.3
207 stmtsql SELECT phrase FROM xtbl LIMIT 4;
208 # Compressed ColumnMetadata
209 callmacro Assert_frame COMPRESSION;
210 # Compressed Row
211 callmacro Assert_frame COMPRESSION;
212 callmacro Assert_frame COMPRESSION;
213 callmacro Assert_frame COMPRESSION;
214 callmacro Assert_frame COMPRESSION;
215 # Compressed Notice
216 callmacro Assert_frame COMPRESSION;
217 # Compressed FetchDone
218 callmacro Assert_frame COMPRESSION;
219 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
220
221
222 -->echo
223 -->echo #
224 -->echo # I.4
225 stmtsql SELECT phrase, prio FROM xtbl LIMIT 4;
226 # Compressed ColumnMetadata
227 callmacro Assert_frame COMPRESSION;
228 callmacro Assert_frame COMPRESSION;
229 # Compressed Row
230 callmacro Assert_frame COMPRESSION;
231 callmacro Assert_frame COMPRESSION;
232 callmacro Assert_frame COMPRESSION;
233 callmacro Assert_frame COMPRESSION;
234 # Compressed Notice
235 callmacro Assert_frame COMPRESSION;
236 # Compressed FetchDone
237 callmacro Assert_frame COMPRESSION;
238 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
239
240 -->echo
241 -->echo #
242 -->echo # I.5
243 stmtsql CALL two_resultsets();
244 # Compressed ColumnMetadata
245 callmacro Assert_frame COMPRESSION;
246 # Compressed Row
247 callmacro Assert_frame COMPRESSION;
248 # Compressed Notice
249 callmacro Assert_frame COMPRESSION;
250 # Compressed FetchMoreResultsets
251 callmacro Assert_frame COMPRESSION;
252 # Compressed ColumnMetadata
253 callmacro Assert_frame COMPRESSION;
254 # Compressed Row
255 callmacro Assert_frame COMPRESSION;
256 # Compressed Notice
257 callmacro Assert_frame COMPRESSION;
258 # Compressed FetchDone
259 callmacro Assert_frame COMPRESSION;
260 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
261
262
263 -->echo
264 -->echo #
265 -->echo # II.1
266 Mysqlx.Crud.Insert {
267 collection {
268 name: "coll"
269 schema: "xtest"
270 }
271 data_model: DOCUMENT
272 row {
273 field {
274 type: LITERAL
275 literal {
276 type: V_STRING
277 v_string {
278 value: "{\"some_field\":\"ok\"}"
279 }
280 }}
281 }
282 }
283 # Compressed Notices
284 callmacro Assert_frame COMPRESSION;
285 callmacro Assert_frame COMPRESSION;
286 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
287
288
289 -->echo
290 -->echo #
291 -->echo # II.2
292 Mysqlx.Crud.Insert {
293 collection {
294 name: "coll"
295 schema: "xtest"
296 }
297 data_model: DOCUMENT
298 row {
299 field {
300 type: LITERAL
301 literal {
302 type: V_STRING
303 v_string {
304 value: "{\"ints\":1}"
305 }
306 }}
307 }
308 row {
309 field {
310 type: LITERAL
311 literal {
312 type: V_STRING
313 v_string {
314 value: "{\"ints\":2}"
315 }
316 }}
317 }
318 row {
319 field {
320 type: LITERAL
321 literal {
322 type: V_STRING
323 v_string {
324 value: "{\"ints\":3}"
325 }
326 }}
327 }
328 row {
329 field {
330 type: LITERAL
331 literal {
332 type: V_STRING
333 v_string {
334 value: "{\"ints\":4}"
335 }
336 }}
337 }
338 }
339 # Compressed Notices
340 callmacro Assert_frame COMPRESSION;
341 callmacro Assert_frame COMPRESSION;
342 callmacro Assert_frame COMPRESSION;
343 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
344
345
346 -->echo
347 -->echo #
348 -->echo # III.1
349 Mysqlx.Crud.Find {
350 collection {
351 name: "coll"
352 schema: "xtest"
353 }
354 data_model: DOCUMENT
355 criteria {
356 type: OPERATOR
357 operator {
358 name: "=="
359 param {
360 type: IDENT
361 identifier {
362 document_path{type:MEMBER value:"not_existing_member"}
363 }
364 }
365 param {
366 type: LITERAL
367 literal {
368 type: V_OCTETS
369 v_octets {value: "non-existing-value"}
370 }
371 }
372 }
373 }
374 }
375 # Compressed ColumnMetaData(doc)
376 callmacro Assert_frame COMPRESSION;
377 # Compressed FetchDone
378 callmacro Assert_frame COMPRESSION;
379 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
380
381
382 -->echo
383 -->echo #
384 -->echo # III.2
385 Mysqlx.Crud.Find {
386 collection {
387 name: "coll"
388 schema: "xtest"
389 }
390 data_model: DOCUMENT
391 limit { row_count:4 }
392 }
393 # Compressed ColumnMetaData(doc)
394 callmacro Assert_frame COMPRESSION;
395 # Compressed Row
396 callmacro Assert_frame COMPRESSION;
397 callmacro Assert_frame COMPRESSION;
398 callmacro Assert_frame COMPRESSION;
399 callmacro Assert_frame COMPRESSION;
400 # Compressed FetchDone
401 callmacro Assert_frame COMPRESSION;
402 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
403
404
405 -->echo
406 -->echo #
407 -->echo # IV.1
408 Mysqlx.Crud.Update {
409 collection {
410 name: "coll"
411 schema: "xtest"
412 }
413 data_model: DOCUMENT
414 criteria {
415 type: OPERATOR
416 operator {
417 name: "=="
418 param {
419 type: IDENT
420 identifier {
421 document_path{type:MEMBER value:"not_existing_member"}
422 }
423 }
424 param {
425 type: LITERAL
426 literal {
427 type: V_OCTETS
428 v_octets {value: "non-existing-value"}
429 }
430 }
431 }
432 }
433 operation{
434 operation:ITEM_SET
435 source{document_path { type: MEMBER value: 'foo' }}
436 value{
437 type: LITERAL
438 literal{ type: V_NULL }
439 }
440 }
441 }
442 # Compressed Notice
443 callmacro Assert_frame COMPRESSION;
444 callmacro Assert_frame COMPRESSION;
445 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
446
447
448 -->echo
449 -->echo #
450 -->echo # IV.2
451 Mysqlx.Crud.Update {
452 collection {
453 name: "coll"
454 schema: "xtest"
455 }
456 data_model: DOCUMENT
457
458 operation{
459 operation:ITEM_SET
460 source{document_path { type: MEMBER value: 'foo2' }}
461 value{
462 type: LITERAL
463 literal{ type: V_NULL }
464 }
465 }
466 }
467 # Compressed Notice
468 callmacro Assert_frame COMPRESSION;
469 callmacro Assert_frame COMPRESSION;
470 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
471
472
473 -->echo
474 -->echo #
475 -->echo # V.1
476 Mysqlx.Crud.Delete {
477 collection {
478 name: "coll"
479 schema: "xtest"
480 }
481 data_model: DOCUMENT
482
483 criteria {
484 type: OPERATOR
485 operator {
486 name: "=="
487 param {
488 type: IDENT
489 identifier {
490 document_path{type:MEMBER value:"not_existing_member"}
491 }
492 }
493 param {
494 type: LITERAL
495 literal {
496 type: V_OCTETS
497 v_octets {value: "non-existing-value"}
498 }
499 }
500 }
501 }
502 }
503 # Compressed Notice
504 callmacro Assert_frame COMPRESSION;
505 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
506
507
508 -->echo
509 -->echo #
510 -->echo # V.2
511 Mysqlx.Crud.Delete {
512 collection {
513 name: "coll"
514 schema: "xtest"
515 }
516 data_model: DOCUMENT
517
518 criteria {
519 type: OPERATOR
520 operator {
521 name: "=="
522 param {
523 type: IDENT
524 identifier {
525 document_path{type:MEMBER value:"prio"}
526 }
527 }
528 param {
529 type: LITERAL
530 literal {
531 type: V_SINT
532 v_signed_int: 1
533 }
534 }
535 }
536 }
537 }
538 # Compressed Notice
539 callmacro Assert_frame COMPRESSION;
540 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
541
542
543 -->echo
544 -->echo #
545 -->echo # VI.1
546 Mysqlx.Prepare.Prepare {
547 stmt_id: 1
548 stmt: {
549 type: STMT
550 stmt_execute: {
551 stmt: "call out_param_no_select(10, ?)"
552 }
553 }
554 }
555 recvok;
556 Mysqlx.Prepare.Execute {
557 stmt_id: 1
558 args {
559 type: SCALAR scalar {
560 type: V_STRING v_string {
561 value: "@my_var"
562 }
563 }
564 }
565 }
566 # Compressed FetchMoreOutParams
567 callmacro Assert_frame COMPRESSION;
568 # Compressed ColumnMetaData
569 callmacro Assert_frame COMPRESSION;
570 # Compressed Row
571 callmacro Assert_frame COMPRESSION;
572 # Compressed FetchDone
573 callmacro Assert_frame COMPRESSION;
574 # Compressed Notice
575 callmacro Assert_frame COMPRESSION;
576 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
577
578
579 -->echo
580 -->echo #
581 -->echo # VI.2
582 Mysqlx.Prepare.Prepare {
583 stmt_id: 2
584 stmt: {
585 type: STMT
586 stmt_execute: {
587 stmt: "SELECT phrase FROM xtbl"
588 }
589 }
590 }
591 recvok;
592
593 Mysqlx.Cursor.Open {
594 cursor_id: 2
595 stmt {
596 type: PREPARE_EXECUTE
597 prepare_execute {
598 stmt_id: 2
599 }
600 }
601 fetch_rows:1
602 }
603 # Compressed ColumnMentaData
604 callmacro Assert_frame COMPRESSION;
605 # Compressed Row
606 callmacro Assert_frame COMPRESSION;
607 # Compressed FetchSuspended
608 callmacro Assert_frame COMPRESSION;
609 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
610
611 EOF
612
613 --let $STORED_PROC_DB_NAME=xtest
614 --source ../include/stored_procedures.inc
615
616 --echo
617 --echo ## A. Execute the test using zlib compression
618 --echo #
619
620 exec $MYSQLXTEST
621 -ux_root --password=''
622 --schema=xtest
623 --compression-mode=required
624 --compression-algorithm=deflate_stream
625 --compression-combine-mixed-messages=0
626 --compression-max-combine-messages=1
627 --file=$MYSQL_TMP_DIR/resultset.xpl 2>&1;
628
629
630 --echo
631 --echo ## B. Execute the test using lz4 compression
632 --echo #
633
634 exec $MYSQLXTEST
635 -ux_root --password=''
636 --schema=xtest
637 --compression-mode=required
638 --compression-algorithm=lz4_message
639 --compression-combine-mixed-messages=0
640 --compression-max-combine-messages=1
641 --file=$MYSQL_TMP_DIR/resultset.xpl 2>&1;
642
643
644 --echo
645 --echo ## C. Execute the test using zstd compression
646 --echo #
647
648 exec $MYSQLXTEST
649 -ux_root --password=''
650 --schema=xtest
651 --compression-mode=required
652 --compression-algorithm=zstd_stream
653 --compression-combine-mixed-messages=0
654 --compression-max-combine-messages=1
655 --file=$MYSQL_TMP_DIR/resultset.xpl 2>&1;
656
657 ## Cleanup
658 --source ../include/xplugin_cleanup.inc