You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Patch #2: Support multi-valued indexes for prepared statements.
Parameters to prepared statements are not denoted as constant but
constant during statement execution, however only constant values are
considered for use with multi-valued indexes.
Replace const_item() with const_for_execution() to enable use of
such parameters with multi-valued indexes.
This is a contribution by Yubao Liu.
Change-Id: I8cf843a95d2657e5fcc67a04df65815f9ad3154a
Copy file name to clipboardExpand all lines: mysql-test/suite/json/r/array_index.result
+150-1Lines changed: 150 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2462,7 +2462,9 @@ f2 JSON NOT NULL,
2462
2462
INDEX idx2 ( (CAST(f2 AS CHAR(50) ARRAY)) )
2463
2463
);
2464
2464
CREATE VIEW v1 AS
2465
-
SELECT * FROM t1, JSON_TABLE(f2, '$[*]' COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH '$')) AS ids;
2465
+
SELECT *
2466
+
FROM t1, JSON_TABLE(f2, '$[*]' COLUMNS(i FOR ORDINALITY, id VARCHAR(50)
2467
+
PATH '$')) AS ids;
2466
2468
INSERT INTO t1 VALUES ('foo', '["aa", "bb"]'), ('bar', '["xx", "yy"]');
2467
2469
ANALYZE TABLE t1;
2468
2470
Table Op Msg_type Msg_text
@@ -2572,6 +2574,153 @@ WHERE json_overlaps(f2, '["xx", "zz"]');
2572
2574
f1 f2 i id
2573
2575
bar ["xx", "yy"] 1 xx
2574
2576
bar ["xx", "yy"] 2 yy
2577
+
PREPARE stmt FROM 'EXPLAIN SELECT * FROM t1 WHERE ? MEMBER OF (f2)';
2578
+
SET @a='xx';
2579
+
EXECUTE stmt USING @a;
2580
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2581
+
1 SIMPLE t1 NULL ref idx2 idx2 203 const 1 100.00 Using where
2582
+
Warnings:
2583
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where json'"xx"' member of (cast(`f2` as char(50) array))
2584
+
PREPARE stmt FROM 'EXPLAIN SELECT * FROM t1 WHERE json_contains(f2, ?)';
2585
+
SET @a='"xx"';
2586
+
EXECUTE stmt USING @a;
2587
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2588
+
1 SIMPLE t1 NULL range idx2 idx2 203 NULL 1 100.00 Using where; Using MRR
2589
+
Warnings:
2590
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where json_contains(cast(`f2` as char(50) array),json'["xx"]')
2591
+
PREPARE stmt FROM 'EXPLAIN SELECT * FROM t1 WHERE json_overlaps(f2, ?)';
2592
+
SET @a='["xx", "cc"]';
2593
+
EXECUTE stmt USING @a;
2594
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2595
+
1 SIMPLE t1 NULL range idx2 idx2 203 NULL 2 100.00 Using where; Using MRR
2596
+
Warnings:
2597
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where json_overlaps(cast(`f2` as char(50) array),json'["xx", "cc"]')
2598
+
PREPARE stmt FROM 'EXPLAIN SELECT * FROM v1 WHERE ? MEMBER OF (f2)';
2599
+
SET @a='xx';
2600
+
EXECUTE stmt USING @a;
2601
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2602
+
1 SIMPLE t1 NULL ref idx2 idx2 203 const 1 100.00 Using where
2603
+
1 SIMPLE ids NULL ALL NULL NULL NULL NULL 2 100.00 Table function: json_table; Using temporary
2604
+
Warnings:
2605
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`ids`.`i` AS `i`,`ids`.`id` AS `id` from `test`.`t1` join json_table(`test`.`t1`.`f2`, '$[*]' columns (`i` for ordinality, `id` varchar(50) character set utf8mb4 path '$')) `ids` where json'"xx"' member of (cast(`f2` as char(50) array))
2606
+
PREPARE stmt FROM 'EXPLAIN SELECT * FROM v1 WHERE json_contains(f2, ?)';
2607
+
SET @a='"xx"';
2608
+
EXECUTE stmt USING @a;
2609
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2610
+
1 SIMPLE t1 NULL range idx2 idx2 203 NULL 1 100.00 Using where; Using MRR
2611
+
1 SIMPLE ids NULL ALL NULL NULL NULL NULL 2 100.00 Table function: json_table; Using temporary
2612
+
Warnings:
2613
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`ids`.`i` AS `i`,`ids`.`id` AS `id` from `test`.`t1` join json_table(`test`.`t1`.`f2`, '$[*]' columns (`i` for ordinality, `id` varchar(50) character set utf8mb4 path '$')) `ids` where json_contains(cast(`f2` as char(50) array),json'["xx"]')
2614
+
PREPARE stmt FROM 'EXPLAIN SELECT * FROM v1 WHERE json_overlaps(f2, ?)';
2615
+
SET @a='["xx", "cc"]';
2616
+
EXECUTE stmt USING @a;
2617
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2618
+
1 SIMPLE t1 NULL range idx2 idx2 203 NULL 2 100.00 Using where; Using MRR
2619
+
1 SIMPLE ids NULL ALL NULL NULL NULL NULL 2 100.00 Table function: json_table; Using temporary
2620
+
Warnings:
2621
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`ids`.`i` AS `i`,`ids`.`id` AS `id` from `test`.`t1` join json_table(`test`.`t1`.`f2`, '$[*]' columns (`i` for ordinality, `id` varchar(50) character set utf8mb4 path '$')) `ids` where json_overlaps(cast(`f2` as char(50) array),json'["xx", "cc"]')
2622
+
PREPARE stmt FROM '
2623
+
EXPLAIN
2624
+
SELECT *
2625
+
FROM t1, JSON_TABLE(f2, \'$[*]\'
2626
+
COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH \'$\')) AS ids
2627
+
WHERE ? MEMBER OF (f2)';
2628
+
SET @a='xx';
2629
+
EXECUTE stmt USING @a;
2630
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2631
+
1 SIMPLE t1 NULL ref idx2 idx2 203 const 1 100.00 Using where
2632
+
1 SIMPLE ids NULL ALL NULL NULL NULL NULL 2 100.00 Table function: json_table; Using temporary
2633
+
Warnings:
2634
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`ids`.`i` AS `i`,`ids`.`id` AS `id` from `test`.`t1` join json_table(`test`.`t1`.`f2`, '$[*]' columns (`i` for ordinality, `id` varchar(50) character set utf8mb4 path '$')) `ids` where json'"xx"' member of (cast(`f2` as char(50) array))
2635
+
PREPARE stmt FROM '
2636
+
EXPLAIN
2637
+
SELECT *
2638
+
FROM t1, JSON_TABLE(f2, \'$[*]\'
2639
+
COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH \'$\')) AS ids
2640
+
WHERE json_contains(f2, ?)';
2641
+
SET @a='"xx"';
2642
+
EXECUTE stmt USING @a;
2643
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2644
+
1 SIMPLE t1 NULL range idx2 idx2 203 NULL 1 100.00 Using where; Using MRR
2645
+
1 SIMPLE ids NULL ALL NULL NULL NULL NULL 2 100.00 Table function: json_table; Using temporary
2646
+
Warnings:
2647
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`ids`.`i` AS `i`,`ids`.`id` AS `id` from `test`.`t1` join json_table(`test`.`t1`.`f2`, '$[*]' columns (`i` for ordinality, `id` varchar(50) character set utf8mb4 path '$')) `ids` where json_contains(cast(`f2` as char(50) array),json'["xx"]')
2648
+
PREPARE stmt FROM '
2649
+
EXPLAIN
2650
+
SELECT *
2651
+
FROM t1, JSON_TABLE(f2, \'$[*]\'
2652
+
COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH \'$\')) AS ids
2653
+
WHERE json_overlaps(f2, ?)';
2654
+
SET @a='["xx", "cc"]';
2655
+
EXECUTE stmt USING @a;
2656
+
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2657
+
1 SIMPLE t1 NULL range idx2 idx2 203 NULL 2 100.00 Using where; Using MRR
2658
+
1 SIMPLE ids NULL ALL NULL NULL NULL NULL 2 100.00 Table function: json_table; Using temporary
2659
+
Warnings:
2660
+
Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`ids`.`i` AS `i`,`ids`.`id` AS `id` from `test`.`t1` join json_table(`test`.`t1`.`f2`, '$[*]' columns (`i` for ordinality, `id` varchar(50) character set utf8mb4 path '$')) `ids` where json_overlaps(cast(`f2` as char(50) array),json'["xx", "cc"]')
2661
+
PREPARE stmt FROM 'SELECT * FROM t1 WHERE ? MEMBER OF (f2)';
2662
+
SET @a='xx';
2663
+
EXECUTE stmt USING @a;
2664
+
f1 f2
2665
+
bar ["xx", "yy"]
2666
+
PREPARE stmt FROM 'SELECT * FROM t1 WHERE json_contains(f2, ?)';
2667
+
SET @a='"xx"';
2668
+
EXECUTE stmt USING @a;
2669
+
f1 f2
2670
+
bar ["xx", "yy"]
2671
+
PREPARE stmt FROM 'SELECT * FROM t1 WHERE json_overlaps(f2, ?)';
2672
+
SET @a='["xx", "cc"]';
2673
+
EXECUTE stmt USING @a;
2674
+
f1 f2
2675
+
bar ["xx", "yy"]
2676
+
PREPARE stmt FROM 'SELECT * FROM v1 WHERE ? MEMBER OF (f2)';
2677
+
SET @a='xx';
2678
+
EXECUTE stmt USING @a;
2679
+
f1 f2 i id
2680
+
bar ["xx", "yy"] 1 xx
2681
+
bar ["xx", "yy"] 2 yy
2682
+
PREPARE stmt FROM 'SELECT * FROM v1 WHERE json_contains(f2, ?)';
2683
+
SET @a='"xx"';
2684
+
EXECUTE stmt USING @a;
2685
+
f1 f2 i id
2686
+
bar ["xx", "yy"] 1 xx
2687
+
bar ["xx", "yy"] 2 yy
2688
+
PREPARE stmt FROM 'SELECT * FROM v1 WHERE json_overlaps(f2, ?)';
2689
+
SET @a='["xx", "cc"]';
2690
+
EXECUTE stmt USING @a;
2691
+
f1 f2 i id
2692
+
bar ["xx", "yy"] 1 xx
2693
+
bar ["xx", "yy"] 2 yy
2694
+
PREPARE stmt FROM '
2695
+
SELECT *
2696
+
FROM t1, JSON_TABLE(f2, \'$[*]\'
2697
+
COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH \'$\')) AS ids
2698
+
WHERE ? MEMBER OF (f2)';
2699
+
SET @a='xx';
2700
+
EXECUTE stmt USING @a;
2701
+
f1 f2 i id
2702
+
bar ["xx", "yy"] 1 xx
2703
+
bar ["xx", "yy"] 2 yy
2704
+
PREPARE stmt FROM '
2705
+
SELECT *
2706
+
FROM t1, JSON_TABLE(f2, \'$[*]\'
2707
+
COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH \'$\')) AS ids
2708
+
WHERE json_contains(f2, ?)';
2709
+
SET @a='"xx"';
2710
+
EXECUTE stmt USING @a;
2711
+
f1 f2 i id
2712
+
bar ["xx", "yy"] 1 xx
2713
+
bar ["xx", "yy"] 2 yy
2714
+
PREPARE stmt FROM '
2715
+
SELECT *
2716
+
FROM t1, JSON_TABLE(f2, \'$[*]\'
2717
+
COLUMNS(i FOR ORDINALITY, id VARCHAR(50) PATH \'$\')) AS ids
0 commit comments