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
[Bug]: JSON_KEYS wildcard paths return NULL instead of an error #28041
JSON_KEYS(json_doc, path) silently returns SQL NULL when path contains * or **. MySQL defines these wildcard paths as invalid for JSON_KEYS() and raises an error instead; returning NULL makes invalid queries indistinguishable from a valid path that selects a non-object or no value.
Control: root JSON_KEYS() returns ["a", "b"]; the ordinary object path $.a returns ["x"] in each run.
No DDL or DML is involved.
Code analysis
pkg/sql/plan/function/func_builtin_json.go:jsonKeysWithPath parses the supplied path and executes bj.Query(...), but does not reject a path containing wildcard legs before querying. A wildcard query returns a non-object aggregate value, and the following val.Type != bytejson.TpCodeObject branch appends SQL NULL. The function needs a dedicated wildcard-path validation before the query.
Regression coverage
After the fix, add deterministic coverage for JSON_KEYS() with root and ordinary object paths, a path selecting a non-object/no value (SQL NULL), and both */** paths (error).
changed the title [-][Compatibility]: JSON_KEYS wildcard paths return NULL instead of an error[/-][+][Bug]: JSON_KEYS wildcard paths return NULL instead of an error[/+]on Sep 3, 2026
MySQL 返回 ERROR 3149 (42000): In this situation, path expressions may not contain the * and ** tokens or an array range.。MatrixOne 当前 main 对 $.* 与 $**.x 均连续 3 次静默返回 SQL NULL。
JSON_KEYS(json_doc, path) 对 typed 通配 *、递归 ** 与数组范围路径按 MySQL 行为拒绝:ERROR 3149 / SQLSTATE 42000,消息 In this situation, path expressions may not contain the * and ** tokens or an array range.
连续三轮执行原始 JSON_KEYS('{"a":{"x":1},"b":{"y":2}}', '$.*'),均返回 3149 / SQLSTATE 42000 和 In this situation, path expressions may not contain the * and ** tokens or an array range.;旧版静默返回 SQL NULL 的现象未再出现。
Activity
[-][Compatibility]: JSON_KEYS wildcard paths return NULL instead of an error[/-][+][Bug]: JSON_KEYS wildcard paths return NULL instead of an error[/+]Ariznawlll commentedon Sep 3, 2026
补充 MySQL 8.0.45 实测:
MySQL 返回
ERROR 3149 (42000): In this situation, path expressions may not contain the * and ** tokens or an array range.。MatrixOne 当前 main 对$.*与$**.x均连续 3 次静默返回 SQLNULL。VioletQwQ-0 commentedon Sep 4, 2026
已完成 #28041 的源码级复核,当前结论如下:
main@494e6a7723242947c73442528e5fbabe62144ec3上,jsonKeysWithPath仍未拒绝 wildcard/range path。ByteJson.Query;non-simple path 的查询结果会被包装为 JSON array,随后落入“非 object → SQL NULL”分支,因而把非法路径吞成了 NULL。JSON_KEYS(json_doc, path)的函数边界:对!path.IsSimple()返回 MySQLER_INVALID_JSON_PATH_WILDCARD(3149 / 42000)。共享 path parser 与 Query 行为不变,允许 wildcard 的其他 JSON 函数不受影响。$.*、$[*]、$**.x、array range,以及$."*"literal key、普通对象路径、未命中、非对象和 NULL 控制,并扩展 canonicalfunc_json_keysBVT。main创建,不堆叠到现有 JSON PR head。Triage decision: remove
needs-triageand addseverity/s1. Assignee andMO-202609milestone remain unchanged.当前证据为源码级分析;PR-head UT、BVT、CI 和 QA 结果将在对应阶段补充。
fix(json): reject wildcard and range paths in JSON_KEYS (#28328)
VioletQwQ-0 commentedon Oct 15, 2026
转测交接:JSON_KEYS 通配/范围路径拒绝(PR #28328 已合并)
@Ariznawlll 你好,#28041 的修复已通过 PR #28328 合入 main,现按流程转测试验收。
合入信息
fix(json): reject wildcard and range paths in JSON_KEYS(head8e38508da)f2093ae4b3cf019802091f6309e31c9524829b70(2026-10-15T07:25:44Z,main)修复范围(对应原 issue 症状)
JSON_KEYS(json_doc, path)对 typed 通配*、递归**与数组范围路径按 MySQL 行为拒绝:ERROR 3149 / SQLSTATE 42000,消息In this situation, path expressions may not contain the * and ** tokens or an array range.*字面量 key 仍合法$[0]、$[last]返回 NULL,真实数组下标不受影响验证证据
SUCCESS=6含 Matrixone CI/UT/BVT 套件;唯一 FAILURE 为MO Checkin Regression On TKE / BUILD MO DOCKER IMAGE镜像构建基建步骤,与产品行为无关;Mergify 自动队列规则 CANCELLED 为出队重排所致)test/distributed/cases/function/func_json_keys.test/.result(生产 SQL 入口断言 3149 错误及上述终态)pkg/container/bytejson/path_test.go、pkg/sql/plan/function/func_json_valid_test.go覆盖新增路径分类与错误码local_self_test_blocked—— 本地磁盘余量约 1.8GiB,且受控远程 mo50 scratch 在活动期间被删除、边界待人工确认,本轮无法在本机/受控远端重建带修复实例;SQL 语义终态已由合并 head 的 required CI + BVT 覆盖请验收的场景(PASS/FAIL 预期)
SELECT JSON_KEYS('{"a":{"x":1},"b":{"y":2}}', '$.*')应返回 ERROR 3149(你 2026-09-03 在 MySQL 8.0.45 实测的同款报错)**、[1 to 3]及其 tab/换行分隔写法)同样 ERROR 3149JSON_KEYS(doc, NULL)返回 NULL;SELECT JSON_KEYS(NULL, '$.*')返回 NULL;带引号"*"的 key 正常返回;JSON_EXTRACT/JSON_LENGTH 合法数组范围行为不变;JSON_SET/JSON_REMOVE/JSON_CONTAINS 范围拒绝不变f2093ae4b的 main 构建或 nightly转测依据:issue 标签
kind/bug+severity/s1,无 compatibility 类标签,按维护约定分配 default tester @Ariznawlll。验证通过后请在本 issue 回复 PASS(注明版本/环境与终态结果),我将据此清理标签并关闭;如 FAIL 请附复现语句与版本,我会加
test-verification-failed并继续修复。Ariznawlll commentedon Oct 15, 2026
测试版本
main461bc8e34920959e5fc141e3d1b37673a90894e1(隔离 worktree 源码构建;embedded 实例不提供有效git_version(),故以构建源码 SHA 标识)f2093ae4b3cf019802091f6309e31c9524829b70已核对为该 main 的祖先原问题验证
连续三轮执行原始
JSON_KEYS('{"a":{"x":1},"b":{"y":2}}', '$.*'),均返回 3149 / SQLSTATE 42000 和In this situation, path expressions may not contain the * and ** tokens or an array range.;旧版静默返回 SQL NULL 的现象未再出现。Happy Path 覆盖
["a", "b"],普通对象路径$.a为["x"];3/3。另用CAST(... AS CHAR)等值断言精确 JSON 值,避免只检查查询完成。$."*"中引号包围的字面量星号 key 合法,返回["x"];3/3,等值断言为真。JSON_EXTRACT('[10,20,30]', '$[0 to 1]')返回[10, 20];3/3,等值断言为真。每轮后SELECT 1返回 1,连接仍可用。Unhappy Path 覆盖
$.*、递归$**.x、数组通配$[*]、数组范围$[0 to 1]:四类无效 path 各 3/3 返回 3149 / 42000;没有被吞成 NULL。错误后正常查询继续成功。白盒验证
本次独立验收为公开 SQL 黑盒测试;未运行 Go UT 或
-race。这些内部测试不替代上述 SQL 结果。回归测试
suites/14_issue_regression/t/issue_28041_json_keys_wildcard.test/r/issue_28041_json_keys_wildcard.result,含精确值与错误码断言。测试证据
wildcard_3149_42000=4 controls=9 extract_range=[10, 20] healthy=1,共三轮。total=3 success=3 failed=0 skipped=0 | stmts=51 ok=51 fail=0。原始旧版现象和 MySQL 对照见 issue 正文及早期评论。测试结论
测试通过。