Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.8.2, 10.8.3, 10.9.1, 10.10.1
-
Arch Linux x86_64
Description
Hi, I'm gsoc-2022 contributor,I'm working on the MCOL-785.
Now I have a problem: My JSON_TYPE implementation return only the first 4 characters:
MariaDB root@(none):test> create table jt_test(i longtext) engine=columnstore;
|
Query OK, 0 rows affected
|
Time: 0.288s
|
MariaDB root@(none):test> insert into jt_test values('{}');
|
Query OK, 1 row affected
|
Time: 0.179s
|
MariaDB root@(none):test> insert into jt_test values("[]");
|
Query OK, 1 row affected
|
Time: 0.134s
|
MariaDB root@(none):test> insert into jt_test values(42);
|
Query OK, 1 row affected
|
Time: 0.116s
|
MariaDB root@(none):test> select json_type(i) from jt_test;
|
+--------------+
|
| json_type(i) |
|
+--------------+
|
| OBJE |
|
| ARRA |
|
| INTE |
|
+--------------+
|
The charset used by json_type() Field is utf8_mb3. When the copy into the Field buffer takes place there is a copy length calculation that divides the length 12 bytes(strange but this is what it is) by 3(max byte per char length for utf8_mb3).So finally the result return 4 characters.
I found here that the max length and collation are set:
bool Item_func_json_type::fix_length_and_dec() |
{
|
collation.set(&my_charset_utf8mb3_general_ci);
|
max_length= 12;
|
set_maybe_null();
|
return FALSE; |
}
|
So I think the max_length should be set 12*collation.collation->mbmaxlen to make json_type in columnstore behave correctly.
- My JSON_TYPE implementation: func_json_type.cpp
- Pull Request: has been submitted and passed CI)
- The Callstack that might be useful (the #0、#1、#2、#3 from_length=6, nchars=4).