diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2018-09-11 14:37:45 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2018-09-11 14:37:45 +0400 |
commit | c8bb43a9385cdb7a27f0702742a8d1e08a85befd (patch) | |
tree | f4375293244135af1f4fd9cfcdbf30f1961749fb /sql/item_jsonfunc.cc | |
parent | 4d9ec7cb6c83c571115bde59d72f02b494764755 (diff) | |
download | mariadb-git-c8bb43a9385cdb7a27f0702742a8d1e08a85befd.tar.gz |
MDEV-17121 JSON_ARRAY_APPEND.
Extra comma added to the result when an json array is empty.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 4a837646451..1da53935441 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1621,13 +1621,15 @@ String *Item_func_json_array_append::val_str(String *str) if (je.value_type == JSON_VALUE_ARRAY) { - if (json_skip_level(&je)) + int n_items; + if (json_skip_level_and_count(&je, &n_items)) goto js_error; ar_end= je.s.c_str - je.sav_c_len; str_rest_len= js->length() - (ar_end - (const uchar *) js->ptr()); str->q_append(js->ptr(), ar_end-(const uchar *) js->ptr()); - str->append(", ", 2); + if (n_items) + str->append(", ", 2); if (append_json_value(str, args[n_arg+1], &tmp_val)) goto return_null; /* Out of memory. */ |