[MDEV-20811] JSON_KEYS does not return error on invalid json doc while documentation says it would Created: 2019-10-11  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Documentation, JSON
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Documentation for JSON_KEYS makes a distinction between "json_doc argument is not an object" (function should return NULL) and "JSON document is invalid" (function should return error). In reality, there seems to be no such difference, the function returns NULL either way:

MariaDB [test]> select json_valid('{"foo"}'), json_keys('{"foo"}');
+-----------------------+----------------------+
| json_valid('{"foo"}') | json_keys('{"foo"}') |
+-----------------------+----------------------+
|                     0 | NULL                 |
+-----------------------+----------------------+
1 row in set, 1 warning (0.000 sec)
 
MariaDB [test]> show warnings;
+---------+------+-------------------------------------------------------------------------------+
| Level   | Code | Message                                                                       |
+---------+------+-------------------------------------------------------------------------------+
| Warning | 4038 | Syntax error in JSON text in argument 1 to function 'json_keys' at position 6 |
+---------+------+-------------------------------------------------------------------------------+
1 row in set (0.000 sec)

Maybe some other case of "JSON document is invalid" was meant, but there is no examples in the documentation or in the MTR test case.

Possibly it's just a documentation issue.


Generated at Thu Feb 08 09:02:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.