Skip to content

Commit 594c6b3

Browse files
author
Alexey Botchkov
committed
MDEV-13138 JSON_OBJECT returns null with strings containing backticks.
Condition was fixed.
1 parent 66a09bd commit 594c6b3

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

mysql-test/r/func_json.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,3 +674,9 @@ JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo')
674674
NULL
675675
Warnings:
676676
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_extract' at position 15
677+
SELECT JSON_OBJECT('foo', '`');
678+
JSON_OBJECT('foo', '`')
679+
{"foo": "`"}
680+
SELECT JSON_OBJECT("foo", "bar`bar");
681+
JSON_OBJECT("foo", "bar`bar")
682+
{"foo": "bar`bar"}

mysql-test/t/func_json.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,9 @@ select JSON_EXTRACT('{\"input1\":\"\\u00f6\"}', '$.\"input1\"');
322322
#
323323
select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');
324324

325+
#
326+
# MDEV-13138 JSON_OBJECT returns null with strings containing backticks.
327+
#
328+
SELECT JSON_OBJECT('foo', '`');
329+
SELECT JSON_OBJECT("foo", "bar`bar");
330+

strings/json_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ int json_escape(CHARSET_INFO *str_cs,
15861586
enum json_esc_char_classes c_class;
15871587

15881588
str+= c_len;
1589-
if (c_chr > 0x60 || (c_class= json_escape_chr_map[c_chr]) == ESC_)
1589+
if (c_chr >= 0x60 || (c_class= json_escape_chr_map[c_chr]) == ESC_)
15901590
{
15911591
if ((c_len= json_cs->cset->wc_mb(json_cs, c_chr, json, json_end)) > 0)
15921592
{

0 commit comments

Comments
 (0)