Commit cc558cfb authored by unknown's avatar unknown
Browse files

Fix for valgrind warning introduced by the fix for bug#21354:

(COUNT(*) = 1) not working in SELECT inside prepared statement.
Note: the warning was introduced in 5.0 and 5.1, 4.1 is OK with the
original fix.

The problem was that in 5.0 and 5.1 clear() for group functions may
access hybrid_type member, and this member is initialized in
fix_fields().

So we should not call clear() from item cleanup() methods, as cleanup()
may be called for unfixed items.


sql/item_sum.cc:
  Do not call clear() from item cleanup() methods, as cleanup() may be
  called for unfixed items, and clear() assumes the item was fixed.
sql/item_sum.h:
  Do not call clear() from item cleanup() methods, as cleanup() may be
  called for unfixed items, and clear() assumes the item was fixed.
parent 687bb161
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1055,7 +1055,7 @@ longlong Item_sum_count::val_int()
void Item_sum_count::cleanup()
{
  DBUG_ENTER("Item_sum_count::cleanup");
  clear();
  count= 0;
  Item_sum_int::cleanup();
  used_table_cache= ~(table_map) 0;
  DBUG_VOID_RETURN;
+5 −4
Original line number Diff line number Diff line
@@ -643,8 +643,8 @@ class Item_sum_avg :public Item_sum_sum
  Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length);
  void cleanup()
  {
    clear();
    Item_sum_num::cleanup();
    count= 0;
    Item_sum_sum::cleanup();
  }
};

@@ -727,7 +727,8 @@ class Item_sum_variance : public Item_sum_num
  enum Item_result result_type () const { return REAL_RESULT; }
  void cleanup()
  {
    clear();
    cur_dec= 0;
    count= 0;
    Item_sum_num::cleanup();
  }
};
@@ -862,7 +863,7 @@ class Item_sum_bit :public Item_sum_int
  { decimals= 0; max_length=21; unsigned_flag= 1; maybe_null= null_value= 0; }
  void cleanup()
  {
    clear();
    bits= reset_bits;
    Item_sum_int::cleanup();
  }
};