summaryrefslogtreecommitdiff
path: root/mysys/my_bitmap.c
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2015-11-06 14:38:03 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2015-11-09 09:28:00 -0500
commit7ec655850397a0edfcea8c1fd82650824297e564 (patch)
treeee9eee5fa9fe5205a7e3950327c17afe93d2cd2a /mysys/my_bitmap.c
parentd6b430c91b6ef6acd0b5adab6106915599c1abcc (diff)
downloadmariadb-git-7ec655850397a0edfcea8c1fd82650824297e564.tar.gz
MDEV-9021: MYSQLD SEGFAULTS WHEN BUILT USING --WITH-MAX-INDEXES=128
The bitmap implementation defines two template Bitmap classes. One optimized for 64-bit (default) wide bitmaps while the other is used for all other widths. In order to optimize the computations, Bitmap<64> class has defined its own member functions for bitmap operations, the other one, however, relies on mysys' bitmap implementation (mysys/my_bitmap.c). Issue 1: In case of non 64-bit Bitmap class, intersect() wrongly reset the received bitmap while initialising a new local bitmap structure (bitmap_init() clears the bitmap buffer) thus, the received bitmap was getting cleared. Fixed by initializing the local bitmap structure by using a temporary buffer and later copying the received bitmap to the initialised bitmap structure. Issue 2: The non 64-bit Bitmap class had the Iterator missing which caused compilation failure. Also added a cmake variable to hold the MAX_INDEXES value when supplied from the command prompt. (eg. cmake .. -DMAX_INDEXES=128U). Checks have been put in place to trigger build failure if MAX_INDEXES value is greater than 128. Test modifications: * Introduced include/have_max_indexes_[64|128].inc to facilitate skipping of tests for which the output differs with different MAX_INDEXES. * Introduced include/max_indexes.inc which would get modified by cmake to reflect the MAX_INDEXES value used to build the server. This file simply sets an mtr variable '$max_indexes' to show the MAX_INDEXES value, which will then be consumed by the above introduced include file. * Some tests (portions), dependent on MAX_INDEXES value, have been moved to separate test files.
Diffstat (limited to 'mysys/my_bitmap.c')
-rw-r--r--mysys/my_bitmap.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 67c478659b5..0eaf1a88aa1 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -306,6 +306,12 @@ uint bitmap_set_next(MY_BITMAP *map)
}
+/**
+ Set the specified number of bits in the bitmap buffer.
+
+ @param map [IN] Bitmap
+ @param prefix_size [IN] Number of bits to be set
+*/
void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size)
{
uint prefix_bytes, prefix_bits, d;
@@ -319,11 +325,12 @@ void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size)
m+= prefix_bytes;
if ((prefix_bits= prefix_size & 7))
{
- *m++= (1 << prefix_bits)-1;
- prefix_bytes++;
+ *(m++)= (1 << prefix_bits)-1;
+ // As the prefix bits are set, lets count this byte too as a prefix byte.
+ prefix_bytes ++;
}
if ((d= no_bytes_in_map(map)-prefix_bytes))
- bzero(m, d);
+ memset(m, 0, d);
}
@@ -373,6 +380,7 @@ my_bool bitmap_is_clear_all(const MY_BITMAP *map)
my_bitmap_map *data_ptr= map->bitmap;
my_bitmap_map *end= map->last_word_ptr;
+ DBUG_ASSERT(map->n_bits > 0);
for (; data_ptr < end; data_ptr++)
if (*data_ptr)
return FALSE;