Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
None
-
None
-
Not for Release Notes
Description
JSON_VALID rejects text with trailing garbage after a valid JSON value, but the reading functions silently accept it, and they also disagree with each other:
Reproduced on 10.11.19 (debug build):
SELECT JSON_VALID('1 x'); -- 0 |
SELECT JSON_LENGTH('1 x'), -- 1 |
JSON_QUERY('[1] x', '$'), -- [1] |
JSON_KEYS('{"a":1} x'), -- ["a"] |
JSON_VALUE('{"a":1} x', '$.a'); -- 1 |
|
|
SELECT JSON_SEARCH('["1"] x', 'one', '1'), -- "$[0]" |
JSON_SEARCH('["1"] x', 'all', '1'); -- NULL (differs from 'one') |
|
|
SELECT JSON_EXISTS('[1] x', '$[0]'), -- 1 |
JSON_CONTAINS_PATH('[1] x', 'one', '$[0]'); -- NULL (differs from JSON_EXISTS) |
Expected: like JSON_CONTAINS_PATH here, all of them treat the argument as invalid and return NULL.
Related: MDEV-40703 (JSON_EXISTS answers 1 for the root path of a malformed document), MDEV-39933 (JSON_NORMALIZE on invalid data).
Attachments
Issue Links
- duplicates
-
MDEV-39956 JSON_KEYS function accept an invalid json
-
- Confirmed
-