Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
10.2(EOL)
-
None
Description
Following on from the comment about the non-working example in MDEV-12877 that MySQL and MariaDB behave the same - they don't in that MySQL gives an error, MariaDB a warning. Is this desirable? Doesn't an error make more sense here?
MySQL 5.7:
SELECT JSON_SEARCH(@json, 'onee', 'AB');
|
ERROR 3154 (42000): The oneOrAll argument to json_search may take these values: 'one' or 'all'.
|
|
select json_extract(json_object('truc',json_array('machin',4,json_object('chose','XML'))),json_search(json_object('truc',json_array('machin',4,json_object('chose','XML'))),'one','XML')) as Result;
|
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 1.
|
MariaDB 10.2
SELECT JSON_SEARCH(@json, 'onee', 'AB');
|
+----------------------------------+
|
| JSON_SEARCH(@json, 'onee', 'AB') |
|
+----------------------------------+
|
| NULL |
|
+----------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
SHOW WARNINGS;
|
+---------+------+--------------------------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+--------------------------------------------------------------+
|
| Warning | 4046 | Argument 2 to function 'json_search' must be "one" or "all". |
|
+---------+------+--------------------------------------------------------------+
|
|
select json_extract(json_object('truc',json_array('machin',4,json_object('chose','XML'))),json_search(json_object('truc',json_array('machin',4,json_object('chose','XML'))),'one','XML')) as Result;
|
+--------+
|
| Result |
|
+--------+
|
| NULL |
|
+--------+
|
1 row in set, 1 warning (0.00 sec)
|
|
mysql [localhost] {msandbox} (test) > SHOW WARNINGS;
|
+---------+------+----------------------------------------------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+----------------------------------------------------------------------------------+
|
| Warning | 4042 | Syntax error in JSON path in argument 2 to function 'json_extract' at position 1 |
|
+---------+------+----------------------------------------------------------------------------------+
|
Attachments
Issue Links
- relates to
-
MDEV-12877 Wrong result from JSON native function.
-
- Closed
-
Unfortunately yes, this is intended.
Our justification is that we've decided to follow standard, which sets the default behavior to be NULL ON ERROR. Standard also describes non-default behavior, configured by ON ERROR clause, but it hasn't been implemented (yet?).
Since standard does not seem to prohibit warnings, our compromise was to at least produce warnings.
More discussion in
MDEV-11826.