diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2017-09-12 15:21:53 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2017-09-12 15:21:53 +0400 |
commit | 0cd731864e6e4d88b75bfea4f02454871aedb89e (patch) | |
tree | 411422ac01b096fd88e374813fa58f10d8339c7b /sql/item_jsonfunc.cc | |
parent | 467acc2119e9408b640915f767515b9242a4d6a3 (diff) | |
download | mariadb-git-0cd731864e6e4d88b75bfea4f02454871aedb89e.tar.gz |
MDEV-13104 Json functions.
An extra ',' added to the JSON_MERGE result making it invalid.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index e5544c6265d..52b3f570844 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1971,14 +1971,25 @@ continue_j2: else { const uchar *end1, *beg1, *end2, *beg2; + int empty_array= 0; beg1= je1->value_begin; /* Merge as a single array. */ if (je1->value_type == JSON_VALUE_ARRAY) { - if (json_skip_level(je1)) + int cur_level= je1->stack_p; + empty_array= 1; + while (json_scan_next(je1) == 0) + { + if (je1->stack_p < cur_level) + break; + empty_array= 0; + } + + if (je1->s.error) return 1; + end1= je1->s.c_str - je1->sav_c_len; } else @@ -1995,8 +2006,8 @@ continue_j2: end1= je1->value_end; } - if (str->append((const char*) beg1, end1 - beg1), - str->append(", ", 2)) + if (str->append((const char*) beg1, end1 - beg1) || + (!empty_array && str->append(", ", 2))) return 3; if (json_value_scalar(je2)) |