matrixorigin / matrixorigin/matrixone

[Compatibility]: JSON_VALUE lacks MySQL RETURNING, ON EMPTY, and ON ERROR clauses

Open
#28,037 0 comments 0 reactions 1 assignee Claimed by @VioletQwQ-0 View on GitHub
kind/bug severity/s1
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

## Description

MatrixOne implements only two-argument `JSON_VALUE(json_doc, path)` and rejects MySQL `RETURNING`, `ON EMPTY`, and `ON ERROR` syntax.

## Environment

- Branch: `main`
- Commit: `17c161a31b47a22e71ca222839143f66717ac365`
- Deployment: local single-node MatrixOne
- Test date: 2026-09-03

## Steps to reproduce

```sql
SELECT JSON_VALUE('{"a":"3"}', '$.a' RETURNING UNSIGNED);\nSELECT JSON_VALUE('{"a":1}', '$.b' DEFAULT 7 ON EMPTY);\nSELECT JSON_VALUE('{"a":"x"}', '$.a' RETURNING UNSIGNED DEFAULT 0 ON ERROR);\n```\n\n## Actual behavior\n\nEach statement is rejected at the optional MySQL clause.\n\n## Expected behavior\n\nMySQL 8.0.21+ supports typed `RETURNING` conversion and explicit `ON EMPTY`/`ON ERROR` outcome control.\n\n## Stability and controls\n\n- Reproducer: `RETURNING` and `DEFAULT ... ON EMPTY` were rejected identically in 3/3 rounds; `ON ERROR` follows the same absent grammar branch.\n- Control: `JSON_VALUE('{"a":"3"}', '$.a')` returned `3` on the same service.\n- Failure atomicity: all reproducers are read-only expressions.\n\n## Evidence\n\nhttps://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html\n\n## Code analysis\n\nThe registry has only two `JSON_VALUE` overloads, both returning `VARCHAR`; the MySQL grammar has no optional-clause production.\n\n## Regression coverage\n\nAfter implementation, add BVT cases for each RETURNING type, missing path, conversion failure, object/array result, defaults, errors, `NULL`, and clause order.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.