|
| 1 | +# basic test |
| 2 | +SET SESSION debug = '+d,test_invisible_index,test_completely_invisible'; |
| 3 | +create table t1 (c int, j json, key idx ((CAST(j->'$.tags' AS CHAR(6) ARRAY))))engine=innodb; |
| 4 | +SHOW CREATE TABLE t1; |
| 5 | +Table Create Table |
| 6 | +t1 CREATE TABLE `t1` ( |
| 7 | + `c` int(11) DEFAULT NULL, |
| 8 | + `j` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`j`)) |
| 9 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 10 | +show index from t1; |
| 11 | +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 12 | +t1 1 invisible1 1 invisible1 A 0 NULL NULL YES BTREE NO |
| 13 | +t1 1 idx 1 DB_MVI_1 NULL NULL NULL NULL YES FULLTEXT NO |
| 14 | +set @old_innodb_ft_aux_table=@@global.innodb_ft_aux_table; |
| 15 | +set global innodb_ft_aux_table='test/t1'; |
| 16 | +insert into t1 values (1, '{"tags": [1, "abcde", "34567", "", 34567]}'); |
| 17 | +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; |
| 18 | +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION |
| 19 | +31xx 1 1 1 1 0 |
| 20 | +3334353637 1 1 1 1 16 |
| 21 | +3334353637 1 1 1 1 16 |
| 22 | +6162636465 1 1 1 1 5 |
| 23 | +xxxx 1 1 1 1 27 |
| 24 | +select json_contains(j->'$.tags', '"abcde"') from t1; |
| 25 | +json_contains(j->'$.tags', '"abcde"') |
| 26 | +1 |
| 27 | +explain |
| 28 | +select * from t1 where json_contains(j->'$.tags', '"abcde"'); |
| 29 | +id select_type table type possible_keys key key_len ref rows Extra |
| 30 | +1 SIMPLE t1 fulltext idx idx 0 1 Using where |
| 31 | +select * from t1 where json_contains(j->'$.tags', '"abcde"'); |
| 32 | +c j |
| 33 | +1 {"tags": [1, "abcde", "34567", "", 34567]} |
| 34 | +DROP TABLE t1; |
| 35 | +set global innodb_ft_aux_table=@old_innodb_ft_aux_table; |
| 36 | +# direct call of mvi_encode |
| 37 | +select mvi_encode('[1, 42, "3"]', int); |
| 38 | +mvi_encode('[1, 42, "3"]', int) |
| 39 | +8000000000000001 800000000000002a 8000000000000003 |
| 40 | +select mvi_encode('[1, 42, "3"]', unsigned); |
| 41 | +mvi_encode('[1, 42, "3"]', unsigned) |
| 42 | +0000000000000001 000000000000002a 0000000000000003 |
| 43 | +select mvi_encode('[1, 42, "3 "]', char(6)); |
| 44 | +mvi_encode('[1, 42, "3 "]', char(6)) |
| 45 | +31xx 3432 33xx |
| 46 | +select mvi_encode('[1, 42, " "]', char(6)); |
| 47 | +mvi_encode('[1, 42, " "]', char(6)) |
| 48 | +31xx 3432 xxxx |
| 49 | +select mvi_encode('[1, 42, "3 "]', binary(6)); |
| 50 | +mvi_encode('[1, 42, "3 "]', binary(6)) |
| 51 | +31xx 3432 33xx |
0 commit comments