summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorDaniel Black <daniel@linux.ibm.com>2019-02-12 15:38:01 +1100
committerSergey Vojtovich <svoj@mariadb.org>2019-02-13 17:35:51 +0400
commita3ccad0f21e48e30c98f91528e3fcbbf2c1d509a (patch)
tree95f8341a4805b2e939af9946dd4494537b32c607 /sql/item_func.cc
parent4e7ee166a9c76eb3546356aabfd2dbc759671cd0 (diff)
downloadmariadb-git-a3ccad0f21e48e30c98f91528e3fcbbf2c1d509a.tar.gz
Aggregate functions: only create list if args exist
Also always empty list rather than only if there is no error.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 72cfd284606..da0e669ae9d 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6515,17 +6515,20 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (m_sp->agg_type() == GROUP_AGGREGATE)
{
- List<Item> list;
- list.empty();
- for (uint i=0; i < arg_count; i++)
- list.push_back(*(args+i));
-
Item_sum_sp *item_sp;
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
if (arg_count)
+ {
+ List<Item> list;
+ list.empty();
+ for (uint i=0; i < arg_count; i++)
+ list.push_back(*(args+i));
+
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp, list);
+ list.empty();
+ }
else
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp);
@@ -6539,7 +6542,6 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (err)
DBUG_RETURN(TRUE);
- list.empty();
DBUG_RETURN(FALSE);
}