diff -Narup ./030_mariadb-10.0.15-partition_auto_inc_init/sql/item_sum.cc ./031_mariadb-10.0.15-direct_aggregate2/sql/item_sum.cc
--- ./030_mariadb-10.0.15-partition_auto_inc_init/sql/item_sum.cc	2014-11-29 17:06:05.911796903 +0900
+++ ./031_mariadb-10.0.15-direct_aggregate2/sql/item_sum.cc	2014-11-29 17:06:59.054797060 +0900
@@ -1199,17 +1199,18 @@ Item_sum_num::fix_fields(THD *thd, Item 
 bool
 Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
 {
+  DBUG_ENTER("Item_sum_hybrid::fix_fields");
   DBUG_ASSERT(fixed == 0);
 
   Item *item= args[0];
 
   if (init_sum_func_check(thd))
-    return TRUE;
+    DBUG_RETURN(TRUE);
 
   // 'item' can be changed during fix_fields
   if ((!item->fixed && item->fix_fields(thd, args)) ||
       (item= args[0])->check_cols(1))
-    return TRUE;
+    DBUG_RETURN(TRUE);
   decimals=item->decimals;
   with_subselect= args[0]->with_subselect;
 
@@ -1241,11 +1242,11 @@ Item_sum_hybrid::fix_fields(THD *thd, It
     hybrid_field_type= Item::field_type();
 
   if (check_sum_func(thd, ref))
-    return TRUE;
+    DBUG_RETURN(TRUE);
 
   orig_args[0]= args[0];
   fixed= 1;
-  return FALSE;
+  DBUG_RETURN(FALSE);
 }
 
 
@@ -1268,15 +1269,16 @@ Item_sum_hybrid::fix_fields(THD *thd, It
 
 void Item_sum_hybrid::setup_hybrid(Item *item, Item *value_arg)
 {
+  DBUG_ENTER("Item_sum_hybrid::setup_hybrid");
   if (!(value= Item_cache::get_cache(item, item->cmp_type())))
-    return;
+    DBUG_VOID_RETURN;
   value->setup(item);
   value->store(value_arg);
   /* Don't cache value, as it will change */
   if (!item->const_item())
     value->set_used_tables(RAND_TABLE_BIT);
   if (!(arg_cache= Item_cache::get_cache(item, item->cmp_type())))
-    return;
+    DBUG_VOID_RETURN;
   arg_cache->setup(item);
   /* Don't cache value, as it will change */
   if (!item->const_item())
@@ -1285,6 +1287,7 @@ void Item_sum_hybrid::setup_hybrid(Item 
   if (cmp)
     cmp->set_cmp_func(this, (Item**)&arg_cache, (Item**)&value, FALSE);
   collation.set(item->collation);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -1292,6 +1295,7 @@ Field *Item_sum_hybrid::create_tmp_field
 					 uint convert_blob_length)
 {
   Field *field;
+  DBUG_ENTER("Item_sum_hybrid::create_tmp_field");
   if (args[0]->type() == Item::FIELD_ITEM)
   {
     field= ((Item_field*) args[0])->field;
@@ -1299,7 +1303,7 @@ Field *Item_sum_hybrid::create_tmp_field
     if ((field= create_tmp_field_from_field(current_thd, field, name, table,
 					    NULL, convert_blob_length)))
       field->flags&= ~NOT_NULL_FLAG;
-    return field;
+    DBUG_RETURN(field);
   }
   /*
     DATE/TIME fields have STRING_RESULT result types.
@@ -1321,11 +1325,11 @@ Field *Item_sum_hybrid::create_tmp_field
                               name, decimals);
     break;
   default:
-    return Item_sum::create_tmp_field(group, table, convert_blob_length);
+    DBUG_RETURN(Item_sum::create_tmp_field(group, table, convert_blob_length));
   }
   if (field)
     field->init(table);
-  return field;
+  DBUG_RETURN(field);
 }
 
 
@@ -2103,8 +2107,10 @@ void Item_sum_variance::update_field()
 
 void Item_sum_hybrid::clear()
 {
+  DBUG_ENTER("Item_sum_hybrid::clear");
   value->clear();
   null_value= 1;
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2120,49 +2126,53 @@ void Item_sum_hybrid::direct_add(Item *i
 
 double Item_sum_hybrid::val_real()
 {
+  DBUG_ENTER("Item_sum_hybrid::val_real");
   DBUG_ASSERT(fixed == 1);
   if (null_value)
-    return 0.0;
+    DBUG_RETURN(0.0);
   double retval= value->val_real();
   if ((null_value= value->null_value))
     DBUG_ASSERT(retval == 0.0);
-  return retval;
+  DBUG_RETURN(retval);
 }
 
 longlong Item_sum_hybrid::val_int()
 {
+  DBUG_ENTER("Item_sum_hybrid::val_int");
   DBUG_ASSERT(fixed == 1);
   if (null_value)
-    return 0;
+    DBUG_RETURN(0);
   longlong retval= value->val_int();
   if ((null_value= value->null_value))
     DBUG_ASSERT(retval == 0);
-  return retval;
+  DBUG_RETURN(retval);
 }
 
 
 my_decimal *Item_sum_hybrid::val_decimal(my_decimal *val)
 {
+  DBUG_ENTER("Item_sum_hybrid::val_decimal");
   DBUG_ASSERT(fixed == 1);
   if (null_value)
-    return 0;
+    DBUG_RETURN(0);
   my_decimal *retval= value->val_decimal(val);
   if ((null_value= value->null_value))
     DBUG_ASSERT(retval == NULL);
-  return retval;
+  DBUG_RETURN(retval);
 }
 
 
 String *
 Item_sum_hybrid::val_str(String *str)
 {
+  DBUG_ENTER("Item_sum_hybrid::val_str");
   DBUG_ASSERT(fixed == 1);
   if (null_value)
-    return 0;
+    DBUG_RETURN(0);
   String *retval= value->val_str(str);
   if ((null_value= value->null_value))
     DBUG_ASSERT(retval == NULL);
-  return retval;
+  DBUG_RETURN(retval);
 }
 
 
@@ -2188,6 +2198,7 @@ void Item_sum_hybrid::cleanup()
 
 void Item_sum_hybrid::no_rows_in_result()
 {
+  DBUG_ENTER("Item_sum_hybrid::no_rows_in_result");
   /* We may be called here twice in case of ref field in function */
   if (was_values)
   {
@@ -2195,6 +2206,7 @@ void Item_sum_hybrid::no_rows_in_result(
     was_null_value= value->null_value;
     clear();
   }
+  DBUG_VOID_RETURN;
 }
 
 void Item_sum_hybrid::restore_to_before_no_rows_in_result()
@@ -2209,9 +2221,10 @@ void Item_sum_hybrid::restore_to_before_
 
 Item *Item_sum_min::copy_or_same(THD* thd)
 {
+  DBUG_ENTER("Item_sum_min::copy_or_same");
   Item_sum_min *item= new (thd->mem_root) Item_sum_min(thd, this);
   item->setup_hybrid(args[0], value);
-  return item;
+  DBUG_RETURN(item);
 }
 
 
@@ -2363,10 +2376,11 @@ void Item_sum_num::reset_field()
 void Item_sum_hybrid::reset_field()
 {
   Item *tmp_item;
+  DBUG_ENTER("Item_sum_hybrid::reset_field");
   if (direct_added)
   {
-    tmp_item= value->get_item();
-    value->store(direct_item);
+    tmp_item= args[0];
+    args[0]= direct_item;
   }
   switch(hybrid_type) {
   case STRING_RESULT:
@@ -2448,9 +2462,10 @@ void Item_sum_hybrid::reset_field()
   }
   if (direct_added)
   {
-    value->store(tmp_item);
+    args[0]= tmp_item;
     direct_added= FALSE;
   }
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2710,6 +2725,7 @@ void Item_sum_avg::update_field()
 void Item_sum_hybrid::update_field()
 {
   Item *tmp_item;
+  DBUG_ENTER("Item_sum_hybrid::update_field");
   if (direct_added)
   {
     tmp_item= value->get_item();
@@ -2733,12 +2749,14 @@ void Item_sum_hybrid::update_field()
     value->store(tmp_item);
     direct_added= FALSE;
   }
+  DBUG_VOID_RETURN;
 }
 
 
 void
 Item_sum_hybrid::min_max_update_str_field()
 {
+  DBUG_ENTER("Item_sum_hybrid::min_max_update_str_field");
   DBUG_ASSERT(cmp);
   String *res_str=args[0]->val_str(&cmp->value1);
 
@@ -2751,6 +2769,7 @@ Item_sum_hybrid::min_max_update_str_fiel
       result_field->store(res_str->ptr(),res_str->length(),res_str->charset());
     result_field->set_notnull();
   }
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2759,6 +2778,7 @@ Item_sum_hybrid::min_max_update_real_fie
 {
   double nr,old_nr;
 
+  DBUG_ENTER("Item_sum_hybrid::min_max_update_real_field");
   old_nr=result_field->val_real();
   nr= args[0]->val_real();
   if (!args[0]->null_value)
@@ -2771,6 +2791,7 @@ Item_sum_hybrid::min_max_update_real_fie
   else if (result_field->is_null(0))
     result_field->set_null();
   result_field->store(old_nr);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2779,6 +2800,7 @@ Item_sum_hybrid::min_max_update_int_fiel
 {
   longlong nr,old_nr;
 
+  DBUG_ENTER("Item_sum_hybrid::min_max_update_int_field");
   old_nr=result_field->val_int();
   nr=args[0]->val_int();
   if (!args[0]->null_value)
@@ -2799,6 +2821,7 @@ Item_sum_hybrid::min_max_update_int_fiel
   else if (result_field->is_null(0))
     result_field->set_null();
   result_field->store(old_nr, unsigned_flag);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2809,6 +2832,7 @@ Item_sum_hybrid::min_max_update_int_fiel
 void
 Item_sum_hybrid::min_max_update_decimal_field()
 {
+  DBUG_ENTER("Item_sum_hybrid::min_max_update_decimal_field");
   my_decimal old_val, nr_val;
   const my_decimal *old_nr;
   const my_decimal *nr= args[0]->val_decimal(&nr_val);
@@ -2829,6 +2853,7 @@ Item_sum_hybrid::min_max_update_decimal_
   }
   else if (result_field->is_null(0))
     result_field->set_null();
+  DBUG_VOID_RETURN;
 }
 
 
