Browse Source

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.
pull/374/head
unknown 19 years ago
parent
commit
cc558cfba3
  1. 2
      sql/item_sum.cc
  2. 9
      sql/item_sum.h

2
sql/item_sum.cc

@ -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;

9
sql/item_sum.h

@ -643,8 +643,8 @@ public:
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 @@ public:
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 @@ public:
{ decimals= 0; max_length=21; unsigned_flag= 1; maybe_null= null_value= 0; }
void cleanup()
{
clear();
bits= reset_bits;
Item_sum_int::cleanup();
}
};

Loading…
Cancel
Save