Details
-
Bug
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
-
11.2(EOL)
-
None
Description
The JSON_KEY_VALUE() (in 11.2) , JSON_QUERY() and JSON_VALUE() function does not print a warning about syntax error if variable is combined with string.
JSON_EXTRACT() does. So the behaviour is non consistent.
11.1.0-dbg>set @json = '{"a":1, "b":2, "c" : 3}'; |
Query OK, 0 rows affected (0.000 sec) |
|
11.1.0-dbg>select @json; |
+-------------------------+ |
| @json |
|
+-------------------------+ |
| {"a":1, "b":2, "c" : 3} | |
+-------------------------+ |
1 row in set (0.000 sec) |
|
11.1.0-dbg>select JSON_KEY_VALUE('{"key1": @json}', '$.key1'); |
+---------------------------------------------+ |
| JSON_KEY_VALUE('{"key1": @json}', '$.key1') | |
+---------------------------------------------+ |
| NULL | |
+---------------------------------------------+ |
1 row in set (0.001 sec) |
|
11.1.0-dbg>
|
Expected syntax error message
11.1.0-dbg>select JSON_KEY_VALUE('{"key1": @json}', '$.key1'); |
ERROR 4038 (HY000): Syntax error in JSON text in argument 1 to function 'JSON_KEY_VALUE' at position x |
11.1.0-dbg>
|
JSON_KEY_VALUE function should also print syntax error if the curly braces are not properly closed
11.1.0-dbg>SELECT JSON_KEY_VALUE('{"key1":{"a":1, "b":2}', '$.key1'); |
+------------------------------------------------------+ |
| JSON_KEY_VALUE('{"key1":{"a":1, "b":2}', '$.key1') | |
+------------------------------------------------------+ |
| [{"key": "a", "value": 1}, {"key": "b", "value": 2}] | |
+------------------------------------------------------+ |
1 row in set (0.000 sec) |
|
11.1.0-dbg>
|
in 10.4:
MariaDB [test]> select json_extract('
{"key1": @json}', '$.key1');
-------------------------------------------
json_extract('
{"key1": @json}
', '$.key1') |
-------------------------------------------
NULL |
-------------------------------------------
1 row in set, 1 warning (0.001 sec)
Warning (Code 4038): Syntax error in JSON text in argument 1 to function 'json_extract' at position 10
Attachments
Issue Links
- relates to
-
MDEV-30145 JSON_TABLE: allow to retrieve the key when iterating on JSON objects
- Closed