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
{{ message }}
Repository navigation
[Compatibility]: JSON_VALUE returns NULL for object and array values that MySQL returns as JSON text #28071
For a simple path that selects a JSON array or object, JSON_VALUE returns SQL NULL in MatrixOne. MySQL 8 returns the selected JSON value as unquoted JSON text. Scalar and missing-path behavior match.
Environment
Branch: main
Commit: 95d04586eb80864499d0fde27aeb912b463ae4cd
Deployment: local single-CN fixture
Control: isolated MySQL 8.0
Date: 2026-09-03
Steps to reproduce
SELECT
JSON_VALUE('{"x":[12],"o":{"k":1},"s":12}', '$.x') AS array_value,
JSON_VALUE('{"x":[12],"o":{"k":1},"s":12}', '$.o') AS object_value,
JSON_VALUE('{"x":[12],"o":{"k":1},"s":12}', '$.s') AS scalar_value;
The same MySQL result is obtained from JSON_UNQUOTE(JSON_EXTRACT(...)); MatrixOne's JSON_UNQUOTE(JSON_EXTRACT(...)) also returns [12] and {"k": 1}, showing that only JSON_VALUE discards the values.
Stability and controls
Reproducer: MatrixOne 3/3; isolated MySQL 8 control 3/3.
Scalar control: $.s returns 12 on both systems.
Missing and JSON-null paths return SQL NULL on both systems.
No mutation is involved.
Code analysis
pkg/sql/plan/function/func_builtin_json.go, JsonValue, explicitly appends SQL NULL when the selected bytejson value is an object or array. The function comment states it is equivalent to JSON_UNQUOTE(JSON_EXTRACT(json_doc, path)), but that public SQL composition retains those values.
Activity
Ariznawlll commentedon Sep 3, 2026
补充影响范围:该差异会传播到基于
JSON_VALUE(doc, '$.x')的存储生成列。MO 将第 1、2 行的
extracted持久化为 SQLNULL,因此WHERE extracted = '[12]'没有匹配行;MySQL 分别持久化[12]和{"k": 1},同一索引查询返回第 1 行。标量第 3 行在两端均为scalar。该结果连续 3 次一致。fix(json): return composite values from JSON_VALUE (#28089)
VioletQwQ-0 commentedon Sep 7, 2026
转测 — PR #28089 / issue #28071
PR #28089 已合并。
be224f382d77c81d028fe8e4beb5661e1bbb6c2c0e2393417feb76abcc3a3a97bb0254e0be876982main@8edac64737db2633c250a527cffdf04707cd8c21JSON_VALUE的用户可见 SQL 结果,并涉及 STORED generated column、二级索引及旧数据升级恢复。开发侧本地自测
main@8edac64737db2633c250a527cffdf04707cd8c21。mo-cgo-test -count=1 -timeout=240s -run '^TestJsonValue$' ./pkg/sql/plan/function:未进入测试,因本机缺少cgo/libmo.dylib和thirdparties/install,属于本地 CGo 环境阻塞,不能记为 PASS。test/distributed/cases/function/func_json_value.test已核对;本机没有mo-tester和可用 MatrixOne 服务,因此未执行 BVT,不能记为 PASS。QA 请补测
main@8edac64737db2633c250a527cffdf04707cd8c21的部署中运行test/distributed/cases/function/func_json_value.test,确认根/嵌套/空 array/object 返回 canonical JSON text,scalar、JSON null、missing path 和多匹配路径保持预期;确认 STORED generated column、FORCE INDEX查询及更新后的索引维护均正确。JSON_VALUESTORED generated column 和二级索引的数据,再升级到该版本;确认旧值不会被静默重算,并按 PR 约定删除依赖索引、删除并按原定义重建 generated column、重建索引后,full scan 与FORCE INDEX的 array/object 查询都返回正确行。预期 PASS:array/object 文本、scalar/null/missing 语义、索引查询和升级恢复全部符合 issue/PR 说明。若 FAIL,请回传实际二进制版本或 SHA、部署拓扑、完整 SQL/命令、预期与实际终态及原始错误/日志定位;尤其请区分旧数据未恢复与新写入数据错误。
Ariznawlll commentedon Sep 8, 2026
测试环境:MatrixOne 最新 main
f72ca9efbeb3a7c673701e4a135cc6670c33cfde,本地单机服务(MySQL 协议 6001)。测试步骤:
JSON_VALUE读取数组、对象、标量、JSON NULL 和缺失路径。测试结果:数组返回
[1, 2],对象返回{"b": 1},标量返回 7;JSON NULL/缺失路径返回 SQL NULL;生成列、索引创建和过滤查询均成功,3/3 结果一致。结论:问题已修复。修复提交 #28089(
0e2393417feb)已包含在当前 main;对应 MOTR 用例已加入 PR #147(https://github.com/matrixorigin/motr/pull/147),MOTR 定向运行通过。fix(json): return composite values from JSON_VALUE (matrixorigin#28089)
fix(json): return composite values from JSON_VALUE (matrixorigin#28089)
fix(json): return composite values from JSON_VALUE (matrixorigin#28089)