[MDEV-12877] Wrong result from JSON native function. Created: 2017-05-23 Updated: 2017-09-13 Resolved: 2017-09-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | JSON |
| Affects Version/s: | 10.2.6 |
| Fix Version/s: | 10.2.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Olivier Bertrand | Assignee: | Alexey Botchkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 10 |
||
| Issue Links: |
|
||||||||
| Description |
|
It seems that JSON functions fail to get returned result from another function:
Sould not the last query return "XML"? |
| Comments |
| Comment by Olivier Bertrand [ 2017-05-29 ] | |||||||||||||||||||||||||
|
It seems that these functions have a general problem recognizing the type of their argument (JSON or not JSON?) for instance:
Normal, the return from JSON_ARRAY is a JSON item.
This time, the function as regarded its second argument as a string.
This is wrong. The description of the JSON_QUERY function says Here the JSON_QUERY function, unlike the JSON_ARRAY one, has regarded its first argument as a valid JSON item since it did not return NULL. Therefore, according to the function description, it should have returned a JSON item like the JSON_ARRAY function does. But this time, its result has been regarded as a string. All this is not coherent. | |||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-06-02 ] | |||||||||||||||||||||||||
|
I agree, there is inconsistency here that cannot be justified by "MariaDB doesn't have JSON type" excuse. It wouldn't be surprising if all the above were treating results of nested functions as strings – that could be explained by the absence of JSON type, – but if example 1 works, there is no obvious reason why example 4 does not. | |||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2017-06-02 ] | |||||||||||||||||||||||||
|
In addition, there is more problems when the argument is the result of a UDF function:
This simply ... make the server crash.
Given that string as argument the function json_extract works fine. | |||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2017-09-12 ] | |||||||||||||||||||||||||
|
What is in the 'Description' part is not a bug. (and yes, MySQL returns just same result.
| |||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2017-09-12 ] | |||||||||||||||||||||||||
This is also the correct result. Both MariaDB and MySQL return this.
| |||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2017-09-12 ] | |||||||||||||||||||||||||
|
This is indeed wrong. FIxed. | |||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2017-09-12 ] | |||||||||||||||||||||||||
|
Crashing UDF call also fixed. | |||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2017-09-13 ] | |||||||||||||||||||||||||
|
Alexey: you probably used a deprecated version of this UDF. Current version returns '$.truc[2].chose'. | |||||||||||||||||||||||||
| Comment by Ian Gilfillan [ 2017-09-13 ] | |||||||||||||||||||||||||
|
MySQL and MariaDB don't behave quite the same in that MariaDB gives a warning, MySQL an error - I've reported this separately as |