Skip to content

Commit

Permalink
MDEV-11468 JSON_UNQUOTE returns incorrect results.
Browse files Browse the repository at this point in the history
        Now return the argument's value when error.
  • Loading branch information
Alexey Botchkov committed Dec 5, 2016
1 parent 0009f4a commit 3743b4c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mysql-test/r/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ drop table t1;
select json_unquote('"abc"');
json_unquote('"abc"')
abc
select json_unquote('abc');
json_unquote('abc')
abc
select json_object("a", json_object("b", "abcd"));
json_object("a", json_object("b", "abcd"))
{"a": {"b": "abcd"}}
Expand Down
1 change: 1 addition & 0 deletions mysql-test/t/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ drop table t1;


select json_unquote('"abc"');
select json_unquote('abc');

select json_object("a", json_object("b", "abcd"));
select json_object("a", '{"b": "abcd"}');
Expand Down
4 changes: 2 additions & 2 deletions sql/item_jsonfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ String *Item_func_json_unquote::val_str(String *str)
return str;

error:
null_value= 1;
return 0;
/* We just return the argument's value in the case of error. */
return js;
}


Expand Down

0 comments on commit 3743b4c

Please sign in to comment.