Debian Codegraph @

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

raw
1 ## Test of specific use of expressions in prepare statement
2
3 ## Preamble
4 --source include/xplugin_preamble.inc
5 --source include/xplugin_create_user.inc
6 ## Test starts here
7
8 --write_file $MYSQL_TMP_DIR/prep_stmt_expr.xpl
9 -->quiet
10
11 -->macro Insert %NAME% %VALUE%
12 Mysqlx.Crud.Insert {
13 collection {
14 name: "%NAME%"
15 schema: "xtest"
16 }
17 data_model: DOCUMENT
18 row {
19 field {
20 type: LITERAL
21 literal {
22 type: V_STRING
23 v_string {
24 value: %VALUE%
25 }
26 }
27 }
28 }
29 }
30 -->recvresult
31 -->endmacro
32
33 -->stmtadmin create_collection {"schema":"xtest", "name":"data"}
34 -->recvresult
35 -->callmacro Insert data '{"_id":"101", "array":["abc","cde","efg"], "scalar":"abc"}'
36 -->callmacro Insert data '{"_id":"102", "array":[123, 345, 567], "scalar":123}'
37 -->callmacro Insert data '{"_id":"103", "array":[2.3, 3.4, 4.5], "scalar":2.3}'
38 -->callmacro Insert data '{"_id":"104", "array":[true, false], "scalar":true}'
39 -->callmacro Insert data '{"_id":"105", "array":[null], "scalar":null}'
40 -->callmacro Insert data '{"_id":"106", "array":["cde", 345, 3.4, true, null], "scalar":"cde"}'
41
42
43 -->title = 1. 'cont_in' operator (placholder_scalar in member_array)
44
45 Mysqlx.Prepare.Prepare {
46 stmt_id: 1
47 stmt {
48 type: FIND
49 find {
50 collection {
51 name: "data"
52 schema: "xtest"
53 }
54 data_model: DOCUMENT
55 criteria {
56 type: OPERATOR
57 operator {
58 name: "cont_in"
59 param {
60 type: PLACEHOLDER
61 position: 0
62 }
63 param {
64 type: IDENT
65 identifier {
66 document_path {
67 type: MEMBER
68 value: "array"
69 }
70 }
71 }
72 }
73 }
74 }
75 }
76 }
77 -->recvok
78
79 -->echo 1.a cont_in operator against string
80
81 Mysqlx.Prepare.Execute {
82 stmt_id: 1
83 args {
84 type: SCALAR
85 scalar {
86 type: V_STRING
87 v_string {
88 value: 'cde'
89 }
90 }
91 }
92 }
93 -->recvresult
94
95 -->echo 1.b cont_in operator against integer
96
97 Mysqlx.Prepare.Execute {
98 stmt_id: 1
99 args {
100 type: SCALAR
101 scalar {
102 type: V_UINT
103 v_unsigned_int: 345
104 }
105 }
106 }
107 -->recvresult
108
109 -->echo 1.c cont_in operator against double
110
111 Mysqlx.Prepare.Execute {
112 stmt_id: 1
113 args {
114 type: SCALAR
115 scalar {
116 type: V_DOUBLE
117 v_double: 3.4
118 }
119 }
120 }
121 -->recvresult
122
123 -->echo 1.d cont_in operator against bool
124
125 Mysqlx.Prepare.Execute {
126 stmt_id: 1
127 args {
128 type: SCALAR
129 scalar {
130 type: V_BOOL
131 v_bool: true
132 }
133 }
134 }
135 -->recvresult
136
137 -->echo 1.e cont_in operator against null
138
139 Mysqlx.Prepare.Execute {
140 stmt_id: 1
141 args {
142 type: SCALAR
143 scalar {
144 type: V_NULL
145 }
146 }
147 }
148 -->recvresult
149
150 Mysqlx.Prepare.Deallocate {
151 stmt_id: 1
152 }
153 -->recvok
154
155 ###############################
156
157 -->title = 2. 'cont_in' operator (member_scalar in placholder_scalar)
158
159 Mysqlx.Prepare.Prepare {
160 stmt_id: 2
161 stmt {
162 type: FIND
163 find {
164 collection {
165 name: "data"
166 schema: "xtest"
167 }
168 data_model: DOCUMENT
169 criteria {
170 type: OPERATOR
171 operator {
172 name: "cont_in"
173 param {
174 type: IDENT
175 identifier {
176 document_path {
177 type: MEMBER
178 value: "scalar"
179 }
180 }
181 }
182 param {
183 type: PLACEHOLDER
184 position: 0
185 }
186 }
187 }
188 }
189 }
190 }
191 -->recvok
192
193 -->echo 2.a cont_in operator against string
194
195 Mysqlx.Prepare.Execute {
196 stmt_id: 2
197 args {
198 type: SCALAR
199 scalar {
200 type: V_STRING
201 v_string {
202 value: 'abc'
203 }
204 }
205 }
206 }
207 -->recvresult
208
209 -->echo 2.b cont_in operator against integer
210
211 Mysqlx.Prepare.Execute {
212 stmt_id: 2
213 args {
214 type: SCALAR
215 scalar {
216 type: V_UINT
217 v_unsigned_int: 123
218 }
219 }
220 }
221 -->recvresult
222
223 -->echo 2.c cont_in operator against double
224
225 Mysqlx.Prepare.Execute {
226 stmt_id: 2
227 args {
228 type: SCALAR
229 scalar {
230 type: V_DOUBLE
231 v_double: 2.3
232 }
233 }
234 }
235 -->recvresult
236
237 -->echo 2.d cont_in operator against bool
238
239 Mysqlx.Prepare.Execute {
240 stmt_id: 2
241 args {
242 type: SCALAR
243 scalar {
244 type: V_BOOL
245 v_bool: true
246 }
247 }
248 }
249 -->recvresult
250
251 -->echo 2.e cont_in operator against null
252
253 Mysqlx.Prepare.Execute {
254 stmt_id: 2
255 args {
256 type: SCALAR
257 scalar {
258 type: V_NULL
259 }
260 }
261 }
262 -->recvresult
263
264 Mysqlx.Prepare.Deallocate {
265 stmt_id: 2
266 }
267 -->recvok
268
269 ###############################
270
271 -->title = 3. 'not_cont_in' operator (placholder_scalar in member_array)
272
273 Mysqlx.Prepare.Prepare {
274 stmt_id: 3
275 stmt {
276 type: FIND
277 find {
278 collection {
279 name: "data"
280 schema: "xtest"
281 }
282 data_model: DOCUMENT
283 criteria {
284 type: OPERATOR
285 operator {
286 name: "not_cont_in"
287 param {
288 type: PLACEHOLDER
289 position: 0
290 }
291 param {
292 type: IDENT
293 identifier {
294 document_path {
295 type: MEMBER
296 value: "array"
297 }
298 }
299 }
300 }
301 }
302 }
303 }
304 }
305 -->recvok
306
307 -->echo 3.a not_cont_in operator against string
308
309 Mysqlx.Prepare.Execute {
310 stmt_id: 3
311 args {
312 type: SCALAR
313 scalar {
314 type: V_STRING
315 v_string {
316 value: 'cde'
317 }
318 }
319 }
320 }
321 -->recvresult
322
323 -->echo 3.b not_cont_in operator against integer
324
325 Mysqlx.Prepare.Execute {
326 stmt_id: 3
327 args {
328 type: SCALAR
329 scalar {
330 type: V_UINT
331 v_unsigned_int: 345
332 }
333 }
334 }
335 -->recvresult
336
337 -->echo 3.c not_cont_in operator against double
338
339 Mysqlx.Prepare.Execute {
340 stmt_id: 3
341 args {
342 type: SCALAR
343 scalar {
344 type: V_DOUBLE
345 v_double: 3.4
346 }
347 }
348 }
349 -->recvresult
350
351 -->echo 3.d not_cont_in operator against bool
352
353 Mysqlx.Prepare.Execute {
354 stmt_id: 3
355 args {
356 type: SCALAR
357 scalar {
358 type: V_BOOL
359 v_bool: true
360 }
361 }
362 }
363 -->recvresult
364
365 -->echo 3.e not_cont_in operator against null
366
367 Mysqlx.Prepare.Execute {
368 stmt_id: 3
369 args {
370 type: SCALAR
371 scalar {
372 type: V_NULL
373 }
374 }
375 }
376 -->recvresult
377
378 Mysqlx.Prepare.Deallocate {
379 stmt_id: 3
380 }
381 -->recvok
382
383 ###############################
384
385 -->title = 4. Simple comparison with placeholder
386
387 Mysqlx.Prepare.Prepare {
388 stmt_id: 4
389 stmt {
390 type: FIND
391 find {
392 collection {
393 name: "data"
394 schema: "xtest"
395 }
396 data_model: DOCUMENT
397 criteria {
398 type: OPERATOR
399 operator {
400 name: "=="
401 param {
402 type: IDENT
403 identifier {
404 document_path {
405 type: MEMBER
406 value: "scalar"
407 }
408 }
409 }
410 param {
411 type: OPERATOR operator {
412 name: "cast"
413 param {
414 type: PLACEHOLDER
415 position: 0
416 }
417 param {
418 type : LITERAL
419 literal { type: V_OCTETS v_octets {value:"JSON"} }
420 }
421 }
422 }
423 }
424 }
425 }
426 }
427 }
428 -->recvok
429
430 -->echo 4.a simple comparison with string
431
432 Mysqlx.Prepare.Execute {
433 stmt_id: 4
434 args {
435 type: SCALAR
436 scalar {
437 type: V_STRING
438 v_string {
439 value: 'abc'
440 }
441 }
442 }
443 }
444 -->recvresult
445
446 -->echo 4.b simple comparison with integer
447
448 Mysqlx.Prepare.Execute {
449 stmt_id: 4
450 args {
451 type: SCALAR
452 scalar {
453 type: V_UINT
454 v_unsigned_int: 123
455 }
456 }
457 }
458 -->recvresult
459
460 -->echo 4.c simple comparison with double
461
462 Mysqlx.Prepare.Execute {
463 stmt_id: 4
464 args {
465 type: SCALAR
466 scalar {
467 type: V_DOUBLE
468 v_double: 2.3
469 }
470 }
471 }
472 -->recvresult
473
474 -->echo 4.d simple comparison with bool
475
476 Mysqlx.Prepare.Execute {
477 stmt_id: 4
478 args {
479 type: SCALAR
480 scalar {
481 type: V_BOOL
482 v_bool: true
483 }
484 }
485 }
486 -->recvresult
487
488 -->echo 4.e simple comparison with null
489
490 Mysqlx.Prepare.Execute {
491 stmt_id: 4
492 args {
493 type: SCALAR
494 scalar {
495 type: V_NULL
496 }
497 }
498 }
499 -->recvresult
500
501 Mysqlx.Prepare.Deallocate {
502 stmt_id: 4
503 }
504 -->recvok
505
506
507 ###############################
508
509 -->title = 5. 'cont_in' operator and '!=' on the same placeholder
510
511 Mysqlx.Prepare.Prepare {
512 stmt_id: 5
513 stmt {
514 type: FIND
515 find {
516 collection {
517 name: "data"
518 schema: "xtest"
519 }
520 data_model: DOCUMENT
521 criteria {
522 type: OPERATOR
523 operator {
524 name: "&&"
525 param {
526 type: OPERATOR
527 operator {
528 name: "cont_in"
529 param {
530 type: PLACEHOLDER position: 0
531 }
532 param {
533 type: IDENT
534 identifier {
535 document_path {
536 type: MEMBER
537 value: "array"
538 }
539 }
540 }
541 }
542 }
543 param {
544 type: OPERATOR
545 operator {
546 name: "!="
547 param {
548 type: IDENT
549 identifier {
550 document_path {
551 type: MEMBER
552 value: "scalar"
553 }
554 }
555 }
556 param {
557 type: PLACEHOLDER position: 0
558 }
559 }
560 }
561 }
562 }
563 }
564 }
565 }
566 -->recvok
567
568 Mysqlx.Prepare.Execute {
569 stmt_id: 5
570 args {
571 type: SCALAR
572 scalar {
573 type: V_STRING
574 v_string {
575 value: 'cde'
576 }
577 }
578 }
579 }
580 -->recvresult
581
582 Mysqlx.Prepare.Deallocate {
583 stmt_id: 5
584 }
585 -->recvok
586
587
588 ###############################
589
590 -->title = 6. 'cont_in' operator (member_scalar in placholder_array)
591
592 Mysqlx.Prepare.Prepare {
593 stmt_id: 6
594 stmt {
595 type: FIND
596 find {
597 collection {
598 name: "data"
599 schema: "xtest"
600 }
601 data_model: DOCUMENT
602 criteria {
603 type: OPERATOR
604 operator {
605 name: "cont_in"
606 param {
607 type: IDENT
608 identifier {
609 document_path {
610 type: MEMBER
611 value: "scalar"
612 }
613 }
614 }
615 param {
616 type: PLACEHOLDER
617 position: 0
618 }
619 }
620 }
621 }
622 }
623 }
624 -->recvok
625
626 -->echo 6.a cont_in operator against string
627
628 Mysqlx.Prepare.Execute {
629 stmt_id: 6
630 args {
631 type: SCALAR
632 scalar {
633 type: V_OCTETS
634 v_octets {
635 value: '["abc","cde"]'
636 content_type: 2
637 }
638 }
639 }
640 }
641 -->recvresult
642
643 -->echo 6.b cont_in operator against integer
644
645 Mysqlx.Prepare.Execute {
646 stmt_id: 6
647 args {
648 type: SCALAR
649 scalar {
650 type: V_OCTETS
651 v_octets {
652 value: '[123, 345]'
653 content_type: 2
654 }
655 }
656 }
657 }
658 -->recvresult
659
660 -->echo 6.c cont_in operator against double
661
662 Mysqlx.Prepare.Execute {
663 stmt_id: 6
664 args {
665 type: SCALAR
666 scalar {
667 type: V_OCTETS
668 v_octets {
669 value: '[2.3, 3.4]'
670 content_type: 2
671 }
672 }
673 }
674 }
675 -->recvresult
676
677 -->echo 6.d cont_in operator against bool
678
679 Mysqlx.Prepare.Execute {
680 stmt_id: 6
681 args {
682 type: SCALAR
683 scalar {
684 type: V_OCTETS
685 v_octets {
686 value: '[true, false]'
687 content_type: 2
688 }
689 }
690 }
691 }
692 -->recvresult
693
694 -->echo 6.e cont_in operator against null
695
696 Mysqlx.Prepare.Execute {
697 stmt_id: 6
698 args {
699 type: SCALAR
700 scalar {
701 type: V_OCTETS
702 v_octets {
703 value: '[null, null]'
704 content_type: 2
705 }
706 }
707 }
708 }
709 -->recvresult
710
711 -->echo 6.e cont_in operator against mix of values
712
713 Mysqlx.Prepare.Execute {
714 stmt_id: 6
715 args {
716 type: SCALAR
717 scalar {
718 type: V_OCTETS
719 v_octets {
720 value: '["abc", 123, 2.3, true, null]'
721 content_type: 2
722 }
723 }
724 }
725 }
726 -->recvresult
727
728 Mysqlx.Prepare.Deallocate {
729 stmt_id: 6
730 }
731 -->recvok
732
733
734 ###############################
735
736 -->title = 7. 'not_cont_in' operator (member_scalar in placholder_array)
737
738 Mysqlx.Prepare.Prepare {
739 stmt_id: 7
740 stmt {
741 type: FIND
742 find {
743 collection {
744 name: "data"
745 schema: "xtest"
746 }
747 data_model: DOCUMENT
748 criteria {
749 type: OPERATOR
750 operator {
751 name: "not_cont_in"
752 param {
753 type: IDENT
754 identifier {
755 document_path {
756 type: MEMBER
757 value: "scalar"
758 }
759 }
760 }
761 param {
762 type: PLACEHOLDER
763 position: 0
764 }
765 }
766 }
767 }
768 }
769 }
770 -->recvok
771
772 -->echo 7.a not_cont_in operator against string
773
774 Mysqlx.Prepare.Execute {
775 stmt_id: 7
776 args {
777 type: SCALAR
778 scalar {
779 type: V_OCTETS
780 v_octets {
781 value: '["abc","cde"]'
782 content_type: 2
783 }
784 }
785 }
786 }
787 -->recvresult
788
789 -->echo 7.b not_cont_in operator against integer
790
791 Mysqlx.Prepare.Execute {
792 stmt_id: 7
793 args {
794 type: SCALAR
795 scalar {
796 type: V_OCTETS
797 v_octets {
798 value: '[123, 345]'
799 content_type: 2
800 }
801 }
802 }
803 }
804 -->recvresult
805
806 -->echo 7.c not_cont_in operator against double
807
808 Mysqlx.Prepare.Execute {
809 stmt_id: 7
810 args {
811 type: SCALAR
812 scalar {
813 type: V_OCTETS
814 v_octets {
815 value: '[2.3, 3.4]'
816 content_type: 2
817 }
818 }
819 }
820 }
821 -->recvresult
822
823 -->echo 7.d not_cont_in operator against bool
824
825 Mysqlx.Prepare.Execute {
826 stmt_id: 7
827 args {
828 type: SCALAR
829 scalar {
830 type: V_OCTETS
831 v_octets {
832 value: '[true, false]'
833 content_type: 2
834 }
835 }
836 }
837 }
838 -->recvresult
839
840 -->echo 7.e not_cont_in operator against null
841
842 Mysqlx.Prepare.Execute {
843 stmt_id: 7
844 args {
845 type: SCALAR
846 scalar {
847 type: V_OCTETS
848 v_octets {
849 value: '[null, null]'
850 content_type: 2
851 }
852 }
853 }
854 }
855 -->recvresult
856
857 -->echo 7.e not_cont_in operator against mix of values
858
859 Mysqlx.Prepare.Execute {
860 stmt_id: 7
861 args {
862 type: SCALAR
863 scalar {
864 type: V_OCTETS
865 v_octets {
866 value: '["abc", 123, 2.3, true, null]'
867 content_type: 2
868 }
869 }
870 }
871 }
872 -->recvresult
873
874 Mysqlx.Prepare.Deallocate {
875 stmt_id: 7
876 }
877 -->recvok
878 EOF
879
880 CREATE SCHEMA IF NOT EXISTS xtest;
881 USE xtest;
882
883
884 exec $MYSQLXTEST
885 -ux_root --password='' --schema=xtest
886 --file=$MYSQL_TMP_DIR/prep_stmt_expr.xpl 2>&1;
887
888 ## Cleanup
889 --source ../include/xplugin_cleanup.inc