From 26af0b96a8d7edb8987ff604f415b3814ee47ece Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Jul 2007 11:31:03 +0200 Subject: [PATCH] Bug#26827 - table->read_set is set incorrectly, causing update of a different column Post-pushbuild fix. bitmap_set_bit() is an inline function in DEBUG builds and a macro in non-DEBUG builds. The latter evaluates its 'bit' argument twice. So one must not use increment/decrement operators on this argument. Moved increment of pointer out of bitmap_set_bit() call. include/my_bitmap.h: Bug#26827 - table->read_set is set incorrectly, causing update of a different column Added a warning comment. sql/sql_partition.cc: Bug#26827 - table->read_set is set incorrectly, causing update of a different column Moved increment of pointer out of bitmap_set_bit() call. --- include/my_bitmap.h | 11 +++++++++++ sql/sql_partition.cc | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 488c41ffb22..0b12172946a 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -103,6 +103,17 @@ extern void bitmap_lock_invert(MY_BITMAP *map); &= ~ (1 << ((BIT) & 7))) #define _bitmap_is_set(MAP, BIT) (uint) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \ & (1 << ((BIT) & 7))) +/* + WARNING! + + The below symbols are inline functions in DEBUG builds and macros in + non-DEBUG builds. The latter evaluate their 'bit' argument twice. + + NEVER use an increment/decrement operator with the 'bit' argument. + It would work with DEBUG builds, but fails later in production builds! + + FORBIDDEN: bitmap_set_bit($my_bitmap, (field++)->field_index); +*/ #ifndef DBUG_OFF static inline void bitmap_set_bit(MY_BITMAP *map,uint bit) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index a44af968d9f..191859e0ed4 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -606,8 +606,8 @@ static bool create_full_part_field_array(THD *thd, TABLE *table, partitioning. */ if ((ptr= part_info->full_part_field_array)) - while (*ptr) - bitmap_set_bit(&part_info->full_part_field_set, (*ptr++)->field_index); + for (; *ptr; ptr++) + bitmap_set_bit(&part_info->full_part_field_set, (*ptr)->field_index); end: DBUG_RETURN(result);