diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2020-06-15 22:51:21 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2020-06-15 22:51:21 +0400 |
commit | 6c573a9146caa76807db1190e0747f5befb5b170 (patch) | |
tree | a304df0f89fa87736623df6c313ff45fe093b526 /sql/item_jsonfunc.cc | |
parent | 30d41c8102c36af7551b3ae77e48efbeb6d7ecea (diff) | |
download | mariadb-git-6c573a9146caa76807db1190e0747f5befb5b170.tar.gz |
MDEV-22844 JSON_ARRAYAGG is limited by group_concat_max_len.
Warning message and function result fixed
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 7e2dc82cf1f..b9a84775311 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -3689,6 +3689,24 @@ String *Item_func_json_arrayagg::get_str_from_field(Item *i,Field *f, } +void Item_func_json_arrayagg::cut_max_length(String *result, + uint old_length, uint max_length) const +{ + if (result->length() == 0) + return; + + if (result->ptr()[result->length() - 1] != '"' || + max_length == 0) + { + Item_func_group_concat::cut_max_length(result, old_length, max_length); + return; + } + + Item_func_group_concat::cut_max_length(result, old_length, max_length-1); + result->append('"'); +} + + String* Item_func_json_arrayagg::val_str(String *str) { if ((str= Item_func_group_concat::val_str(str))) |