Repository navigation
Description
Description
JSON_VALUE 目前拒绝带通配符或递归下降的合法 JSON 路径;MySQL 8 对相同输入会按 JSON_VALUE 的标量结果规则返回 NULL 或标量。该差异会使使用通用 JSON 路径的 MySQL SQL 在 MO 上直接报错。
Environment
- Branch:
main - Commit:
399cbaa0046e3d051a3c1460690df574c9386783 - Deployment: local single-CN fixture
- Client: MySQL Connector/J 8.0.33
- Control: MySQL 8.0.46
- Date: 2026-08-22
Steps to reproduce
Execute each statement independently:
SELECT JSON_VALUE('{"a":1,"b":2}', '$.*');
SELECT JSON_VALUE('{"a":1,"b":2}', '$[*]');
SELECT JSON_VALUE('{"a":1,"b":2}', '$**.a');Actual behavior
MO returns HY000 / 20203 for all three statements (invalid path expression).
Expected behavior
MySQL 8.0.46 returns:
| Path | Result |
|---|---|
$.* |
NULL (multiple scalar matches cannot form one JSON_VALUE) |
$[*] |
NULL (no match in this document) |
$**.a |
1 (one scalar match) |
MO should align with the corresponding scalar/NULL outcome instead of rejecting the path solely because it is non-simple.
Stability and controls
- Reproducer: 3/3 on MO, identical
HY000/20203result for all three paths. - Connection reuse: after every rejected statement,
SELECT 1succeeded on the same JDBC connection. - Normal control: simple paths such as
JSON_VALUE('{"a":1}', '$.a')return1on both MO and MySQL. - Error controls: malformed JSON, malformed path, invalid modifying paths, odd
JSON_OBJECTarguments, and insufficientJSON_MERGE_PATCHarguments are rejected on both sides. - Data mutation check: the JSON mutation failure matrix left all rows unchanged after each rejected update.
Code analysis
The current implementation intentionally applies a simple-path restriction. The distributed case test/distributed/cases/function/func_json_value.test contains a case that expects an error for $.*. This explains the deterministic result but does not match the MySQL control behavior above.
Regression coverage
After the behavior is aligned, add BVT coverage for $.*, $[*], and $**.a, including scalar, no-match, and multiple-match outcomes.
Related
- [Bug]:3.0-dev not supported function 1 #24481 is a closed historical function-availability issue; it does not cover this
JSON_VALUEpath-semantics difference.
Activity
Ariznawlll commentedon Aug 24, 2026
测试版本
mainba8954d543af0bdfb1948a8b89f77f5235ac9259原问题验证
连续 3 轮执行
JSON_VALUE路径矩阵:$.*(多匹配)和$[*](无匹配)均返回 NULL,$**.a返回标量1;简单路径$.a作为对照也返回1。Happy Path 覆盖
$.*返回 NULL。$[*]返回 NULL。$**.a返回唯一标量;简单路径对照正确。Unhappy Path 覆盖
$.a。白盒验证
不适用:公开 SQL 覆盖了标量、无匹配、多匹配、非法读取与非法修改的结果和状态。
回归测试
issue_27481_json_value_wildcards.test。33/33语句成功。测试证据
a6a562a1。测试结论
测试通过。