Description:
The test case json.array_index_debug shows a result mismatch under the cursor-protocol.
@@ -8,7 +8,7 @@
SET debug = '+d,show_hidden_columns';
SELECT * FROM t;
j !hidden!k!0!0
-[1, 2, 3] [1, 2, 3]
+[1, 2, 3] null
How to repeat:
It is necessary to first include the fix in this bugfix https://bugs.mysql.com/bug.php?id=118372, so that mtr --cursor-protocol can run normally.
Then run "mtr json.array_index_debug --cursor-protocol".
Suggested fix:
The content of the json.array_index_debug test case:
CREATE TABLE t(j JSON, KEY k ((CAST(j->'$[*]' AS SIGNED ARRAY))));
INSERT INTO t VALUES ('[1,2,3]');
SET debug = '+d,show_hidden_columns';
SELECT * FROM t;
When converting the field type from JSON to a signed array here, under the cursor protocol, the content will be first stored in a temporary table.
During the process of writing to the temporary table, the hidden column attempts to recognize '[1,2,3]' as a longlong type (Field_typed_array::store() in the code ), resulting in a recognition failure and ultimately storing it as null. Obviously, there is an issue with the type conversion here.