Skip to content

Commit 3743b4c

Browse files
author
Alexey Botchkov
committed
MDEV-11468 JSON_UNQUOTE returns incorrect results.
Now return the argument's value when error.
1 parent 0009f4a commit 3743b4c

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

mysql-test/r/func_json.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ drop table t1;
277277
select json_unquote('"abc"');
278278
json_unquote('"abc"')
279279
abc
280+
select json_unquote('abc');
281+
json_unquote('abc')
282+
abc
280283
select json_object("a", json_object("b", "abcd"));
281284
json_object("a", json_object("b", "abcd"))
282285
{"a": {"b": "abcd"}}

mysql-test/t/func_json.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ drop table t1;
121121

122122

123123
select json_unquote('"abc"');
124+
select json_unquote('abc');
124125

125126
select json_object("a", json_object("b", "abcd"));
126127
select json_object("a", '{"b": "abcd"}');

sql/item_jsonfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ String *Item_func_json_unquote::val_str(String *str)
359359
return str;
360360

361361
error:
362-
null_value= 1;
363-
return 0;
362+
/* We just return the argument's value in the case of error. */
363+
return js;
364364
}
365365

366366

0 commit comments

Comments
 (0)