From 3743b4c3ef64223bd2e35874d9ab22f46bcf504d Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 6 Dec 2016 00:34:25 +0400 Subject: [PATCH] MDEV-11468 JSON_UNQUOTE returns incorrect results. Now return the argument's value when error. --- mysql-test/r/func_json.result | 3 +++ mysql-test/t/func_json.test | 1 + sql/item_jsonfunc.cc | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index 36430973fe7..df34e5b80bc 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -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"}} diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index 62853de6ad2..357f223f579 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -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"}'); diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index cb1c174d08d..c3b4bc7b8b5 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -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; }