Skip to content

Commit a3ccad0

Browse files
grooverdansvoj
authored andcommitted
Aggregate functions: only create list if args exist
Also always empty list rather than only if there is no error.
1 parent 4e7ee16 commit a3ccad0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sql/item_func.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6515,17 +6515,20 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
65156515

65166516
if (m_sp->agg_type() == GROUP_AGGREGATE)
65176517
{
6518-
List<Item> list;
6519-
list.empty();
6520-
for (uint i=0; i < arg_count; i++)
6521-
list.push_back(*(args+i));
6522-
65236518
Item_sum_sp *item_sp;
65246519
Query_arena *arena, backup;
65256520
arena= thd->activate_stmt_arena_if_needed(&backup);
65266521

65276522
if (arg_count)
6523+
{
6524+
List<Item> list;
6525+
list.empty();
6526+
for (uint i=0; i < arg_count; i++)
6527+
list.push_back(*(args+i));
6528+
65286529
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp, list);
6530+
list.empty();
6531+
}
65296532
else
65306533
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp);
65316534

@@ -6539,7 +6542,6 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
65396542
if (err)
65406543
DBUG_RETURN(TRUE);
65416544

6542-
list.empty();
65436545
DBUG_RETURN(FALSE);
65446546
}
65456547

0 commit comments

Comments
 (0)