summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2019-10-10 00:31:59 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2019-10-10 00:31:59 +0400
commit7dc74bb3b5d831adc9c355163725eb968569a806 (patch)
treecfe932b087890724dfb1c5ef40fb51fb625fa28c /sql/item_sum.cc
parentb37386d854b37743a7b4ae578312dd27bec055ce (diff)
parentd0fc07c85f1b01291c78a9ea42525d57df7b66b7 (diff)
downloadmariadb-git-7dc74bb3b5d831adc9c355163725eb968569a806.tar.gz
Merge branch 'MDEV-16620' of https://github.com/markus456/server into bb-10.5-hf
Conflicts: sql/sql_yacc.yy
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index c4a50470690..5476ddd9151 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3652,6 +3652,14 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
if (item->limit_clause && !(*row_limit))
return 1;
+ if (item->sum_func() == Item_sum::JSON_ARRAYAGG_FUNC &&
+ item->arg_count_field > 1)
+ {
+ /* JSON_ARRAYAGG supports only one parameter */
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), "JSON_ARRAYAGG");
+ return 1;
+ }
+
if (item->no_appended)
item->no_appended= FALSE;
else
@@ -3693,7 +3701,19 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
res= (*arg)->val_str(&tmp);
}
if (res)
+ {
+ if (item->sum_func() == Item_sum::JSON_ARRAYAGG_FUNC)
+ {
+ /*
+ JSON_ARRAYAGG needs to convert the type into valid JSON before
+ appending it to the result
+ */
+ Item_func_json_arrayagg *arrayagg= (Item_func_json_arrayagg *) item_arg;
+ res= arrayagg->convert_to_json(*arg, res);
+ }
+
result->append(*res);
+ }
}
if (item->limit_clause)
@@ -3999,9 +4019,9 @@ bool Item_func_group_concat::repack_tree(THD *thd)
*/
#define GCONCAT_REPACK_FACTOR (1 << 10)
-bool Item_func_group_concat::add()
+bool Item_func_group_concat::add(bool exclude_nulls)
{
- if (always_null)
+ if (always_null && exclude_nulls)
return 0;
copy_fields(tmp_table_param);
if (copy_funcs(tmp_table_param->items_to_copy, table->in_use))
@@ -4019,7 +4039,8 @@ bool Item_func_group_concat::add()
Field *field= show_item->get_tmp_table_field();
if (field)
{
- if (field->is_null_in_record((const uchar*) table->record[0]))
+ if (field->is_null_in_record((const uchar*) table->record[0]) &&
+ exclude_nulls)
return 0; // Skip row if it contains null
if (tree && (res= field->val_str(&buf)))
row_str_len+= res->length();