1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-17121 JSON_ARRAY_APPEND.

Extra comma added to the result when an json array is empty.
This commit is contained in:
Alexey Botchkov
2018-09-11 14:37:45 +04:00
parent 4d9ec7cb6c
commit c8bb43a938
5 changed files with 48 additions and 2 deletions

View File

@ -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. */