Bug #118488 Cursor Protocol JSON-to-Array Conversion Yields Incorrect Results

Submitted: 19 Jun 2025 11:03 Modified: 19 Jun 2025 11:54
Reporter: Xingyu Yang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S7 (Test Cases)
Version:8.0,9.2, 8.0.42, 8.4.5 OS:Any
Assigned to: CPU Architecture:Any

[19 Jun 2025 11:03] Xingyu Yang
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.
[19 Jun 2025 11:54] MySQL Verification Team
Hello Xingyu Yang,

Thank you for the report and feedback.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.