cleanup: MY_BITMAP mutex

in about a hundred of users of MY_BITMAP, only two were using its
built-in mutex, and only one of those two was actually needing it.

Remove the mutex from MY_BITMAP, remove all associated conditions
and checks in bitmap functions. Use an external LOCK_temp_pool
mutex and temp_pool_set_next/temp_pool_clear_bit acccessors.

Remove bitmap_init/bitmap_free, always use my_* versions.
This commit is contained in:
Sergei Golubchik 2021-07-17 08:57:29 +02:00
parent 05e29e177d
commit 0299ec29d4
27 changed files with 106 additions and 170 deletions

View File

@ -28,12 +28,6 @@ typedef struct st_bitmap
{ {
my_bitmap_map *bitmap; my_bitmap_map *bitmap;
my_bitmap_map *last_word_ptr; my_bitmap_map *last_word_ptr;
/*
mutex will be acquired for the duration of each bitmap operation if
thread_safe flag in bitmap_init was set. Otherwise, we optimize by not
acquiring the mutex
*/
mysql_mutex_t *mutex;
my_bitmap_map last_word_mask; my_bitmap_map last_word_mask;
uint32 n_bits; /* number of bits occupied by the above */ uint32 n_bits; /* number of bits occupied by the above */
} MY_BITMAP; } MY_BITMAP;
@ -42,15 +36,11 @@ typedef struct st_bitmap
extern "C" { extern "C" {
#endif #endif
/* compatibility functions */
#define bitmap_init(A,B,C,D) my_bitmap_init(A,B,C,D)
#define bitmap_free(A) my_bitmap_free(A)
/* Reset memory. Faster then doing a full bzero */ /* Reset memory. Faster then doing a full bzero */
#define my_bitmap_clear(A) ((A)->bitmap= 0) #define my_bitmap_clear(A) ((A)->bitmap= 0)
extern void create_last_word_mask(MY_BITMAP *map); extern void create_last_word_mask(MY_BITMAP *map);
extern my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits, extern my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits);
my_bool thread_safe);
extern my_bool bitmap_is_clear_all(const MY_BITMAP *map); extern my_bool bitmap_is_clear_all(const MY_BITMAP *map);
extern my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size); extern my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size);
extern my_bool bitmap_is_set_all(const MY_BITMAP *map); extern my_bool bitmap_is_set_all(const MY_BITMAP *map);
@ -82,8 +72,6 @@ extern void bitmap_xor(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_invert(MY_BITMAP *map); extern void bitmap_invert(MY_BITMAP *map);
extern void bitmap_copy(MY_BITMAP *map, const MY_BITMAP *map2); extern void bitmap_copy(MY_BITMAP *map, const MY_BITMAP *map2);
extern uint bitmap_lock_set_next(MY_BITMAP *map);
extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit);
/* Fast, not thread safe, bitmap functions */ /* Fast, not thread safe, bitmap functions */
#define bitmap_buffer_size(bits) (((bits)+31)/32)*4 #define bitmap_buffer_size(bits) (((bits)+31)/32)*4
#define no_bytes_in_map(map) (((map)->n_bits + 7)/8) #define no_bytes_in_map(map) (((map)->n_bits + 7)/8)

View File

@ -123,19 +123,6 @@ static inline my_bitmap_map last_word_mask(uint bit)
} }
static inline void bitmap_lock(MY_BITMAP *map __attribute__((unused)))
{
if (map->mutex)
mysql_mutex_lock(map->mutex);
}
static inline void bitmap_unlock(MY_BITMAP *map __attribute__((unused)))
{
if (map->mutex)
mysql_mutex_unlock(map->mutex);
}
static inline uint get_first_set(my_bitmap_map value, uint word_pos) static inline uint get_first_set(my_bitmap_map value, uint word_pos)
{ {
uchar *byte_ptr= (uchar*)&value; uchar *byte_ptr= (uchar*)&value;
@ -159,32 +146,15 @@ static inline uint get_first_set(my_bitmap_map value, uint word_pos)
Initialize a bitmap object. All bits will be set to zero Initialize a bitmap object. All bits will be set to zero
*/ */
my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits, my_bool my_bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits)
my_bool thread_safe)
{ {
DBUG_ENTER("my_bitmap_init"); DBUG_ENTER("my_bitmap_init");
map->mutex= 0;
if (!buf) if (!buf)
{ {
uint size_in_bytes= bitmap_buffer_size(n_bits); uint size_in_bytes= bitmap_buffer_size(n_bits);
uint extra= 0;
if (thread_safe)
{
size_in_bytes= ALIGN_SIZE(size_in_bytes);
extra= sizeof(mysql_mutex_t);
}
if (!(buf= (my_bitmap_map*) my_malloc(key_memory_MY_BITMAP_bitmap, if (!(buf= (my_bitmap_map*) my_malloc(key_memory_MY_BITMAP_bitmap,
size_in_bytes+extra, MYF(MY_WME)))) size_in_bytes, MYF(MY_WME))))
DBUG_RETURN(1); DBUG_RETURN(1);
if (thread_safe)
{
map->mutex= (mysql_mutex_t *) ((char*) buf + size_in_bytes);
mysql_mutex_init(key_BITMAP_mutex, map->mutex, MY_MUTEX_INIT_FAST);
}
}
else
{
DBUG_ASSERT(thread_safe == 0);
} }
map->bitmap= buf; map->bitmap= buf;
@ -200,8 +170,6 @@ void my_bitmap_free(MY_BITMAP *map)
DBUG_ENTER("my_bitmap_free"); DBUG_ENTER("my_bitmap_free");
if (map->bitmap) if (map->bitmap)
{ {
if (map->mutex)
mysql_mutex_destroy(map->mutex);
my_free(map->bitmap); my_free(map->bitmap);
map->bitmap=0; map->bitmap=0;
} }
@ -247,13 +215,9 @@ my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit)
my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit) my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit)
{ {
my_bool res;
DBUG_ASSERT(map->bitmap); DBUG_ASSERT(map->bitmap);
DBUG_ASSERT(bitmap_bit < map->n_bits); DBUG_ASSERT(bitmap_bit < map->n_bits);
bitmap_lock(map); return bitmap_fast_test_and_set(map, bitmap_bit);
res= bitmap_fast_test_and_set(map, bitmap_bit);
bitmap_unlock(map);
return res;
} }
/* /*
@ -281,13 +245,9 @@ my_bool bitmap_fast_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit) my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
{ {
my_bool res;
DBUG_ASSERT(map->bitmap); DBUG_ASSERT(map->bitmap);
DBUG_ASSERT(bitmap_bit < map->n_bits); DBUG_ASSERT(bitmap_bit < map->n_bits);
bitmap_lock(map); return bitmap_fast_test_and_clear(map, bitmap_bit);
res= bitmap_fast_test_and_clear(map, bitmap_bit);
bitmap_unlock(map);
return res;
} }
@ -733,24 +693,3 @@ found:
DBUG_ASSERT(0); DBUG_ASSERT(0);
return MY_BIT_NONE; /* Impossible */ return MY_BIT_NONE; /* Impossible */
} }
uint bitmap_lock_set_next(MY_BITMAP *map)
{
uint bit_found;
bitmap_lock(map);
bit_found= bitmap_set_next(map);
bitmap_unlock(map);
return bit_found;
}
void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit)
{
bitmap_lock(map);
DBUG_ASSERT(map->bitmap);
DBUG_ASSERT(bitmap_bit < map->n_bits);
bitmap_clear_bit(map, bitmap_bit);
bitmap_unlock(map);
}

View File

@ -3537,31 +3537,31 @@ bool ha_partition::init_partition_bitmaps()
DBUG_ENTER("ha_partition::init_partition_bitmaps"); DBUG_ENTER("ha_partition::init_partition_bitmaps");
/* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */ /* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */
if (my_bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1, FALSE)) if (my_bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1))
DBUG_RETURN(true); DBUG_RETURN(true);
/* Initialize the bitmap we use to keep track of locked partitions */ /* Initialize the bitmap we use to keep track of locked partitions */
if (my_bitmap_init(&m_locked_partitions, NULL, m_tot_parts, FALSE)) if (my_bitmap_init(&m_locked_partitions, NULL, m_tot_parts))
DBUG_RETURN(true); DBUG_RETURN(true);
/* /*
Initialize the bitmap we use to keep track of partitions which may have Initialize the bitmap we use to keep track of partitions which may have
something to reset in ha_reset(). something to reset in ha_reset().
*/ */
if (my_bitmap_init(&m_partitions_to_reset, NULL, m_tot_parts, FALSE)) if (my_bitmap_init(&m_partitions_to_reset, NULL, m_tot_parts))
DBUG_RETURN(true); DBUG_RETURN(true);
/* /*
Initialize the bitmap we use to keep track of partitions which returned Initialize the bitmap we use to keep track of partitions which returned
HA_ERR_KEY_NOT_FOUND from index_read_map. HA_ERR_KEY_NOT_FOUND from index_read_map.
*/ */
if (my_bitmap_init(&m_key_not_found_partitions, NULL, m_tot_parts, FALSE)) if (my_bitmap_init(&m_key_not_found_partitions, NULL, m_tot_parts))
DBUG_RETURN(true); DBUG_RETURN(true);
if (bitmap_init(&m_mrr_used_partitions, NULL, m_tot_parts, TRUE)) if (my_bitmap_init(&m_mrr_used_partitions, NULL, m_tot_parts))
DBUG_RETURN(true); DBUG_RETURN(true);
if (my_bitmap_init(&m_opened_partitions, NULL, m_tot_parts, FALSE)) if (my_bitmap_init(&m_opened_partitions, NULL, m_tot_parts))
DBUG_RETURN(true); DBUG_RETURN(true);
m_file_sample= NULL; m_file_sample= NULL;

View File

@ -5119,7 +5119,7 @@ my_bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root)
if (!(bitmap_buf= (my_bitmap_map*) alloc_root(mem_root, if (!(bitmap_buf= (my_bitmap_map*) alloc_root(mem_root,
bitmap_buffer_size(n_bits))) || bitmap_buffer_size(n_bits))) ||
my_bitmap_init(map, bitmap_buf, n_bits, FALSE)) my_bitmap_init(map, bitmap_buf, n_bits))
return TRUE; return TRUE;
bitmap_clear_all(map); bitmap_clear_all(map);
return FALSE; return FALSE;
@ -6011,7 +6011,7 @@ bool Ordered_key::alloc_keys_buffers()
lookup offset. lookup offset.
*/ */
/* Notice that max_null_row is max array index, we need count, so +1. */ /* Notice that max_null_row is max array index, we need count, so +1. */
if (my_bitmap_init(&null_key, NULL, (uint)(max_null_row + 1), FALSE)) if (my_bitmap_init(&null_key, NULL, (uint)(max_null_row + 1)))
return TRUE; return TRUE;
cur_key_idx= HA_POS_ERROR; cur_key_idx= HA_POS_ERROR;

View File

@ -835,8 +835,7 @@ TABLE *create_table_for_function(THD *thd, TABLE_LIST *sql_table)
my_bitmap_map* bitmaps= my_bitmap_map* bitmaps=
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count)); (my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count, my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count);
FALSE);
table->read_set= &table->def_read_set; table->read_set= &table->def_read_set;
bitmap_clear_all(table->read_set); bitmap_clear_all(table->read_set);
table->alias_name_used= true; table->alias_name_used= true;

View File

@ -3321,8 +3321,7 @@ Rows_log_event::Rows_log_event(const uchar *buf, uint event_len,
/* if my_bitmap_init fails, caught in is_valid() */ /* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols, if (likely(!my_bitmap_init(&m_cols,
m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
m_width, m_width)))
false)))
{ {
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8); memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8);
@ -3346,8 +3345,7 @@ Rows_log_event::Rows_log_event(const uchar *buf, uint event_len,
/* if my_bitmap_init fails, caught in is_valid() */ /* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols_ai, if (likely(!my_bitmap_init(&m_cols_ai,
m_width <= sizeof(m_bitbuf_ai)*8 ? m_bitbuf_ai : NULL, m_width <= sizeof(m_bitbuf_ai)*8 ? m_bitbuf_ai : NULL,
m_width, m_width)))
false)))
{ {
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
memcpy(m_cols_ai.bitmap, ptr_after_width, (m_width + 7) / 8); memcpy(m_cols_ai.bitmap, ptr_after_width, (m_width + 7) / 8);

View File

@ -1156,8 +1156,7 @@ Old_rows_log_event::Old_rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
/* if my_bitmap_init fails, caught in is_valid() */ /* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols, if (likely(!my_bitmap_init(&m_cols,
m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
m_width, m_width)))
false)))
{ {
/* Cols can be zero if this is a dummy binrows event */ /* Cols can be zero if this is a dummy binrows event */
if (likely(cols != NULL)) if (likely(cols != NULL))
@ -1232,8 +1231,7 @@ Old_rows_log_event::Old_rows_log_event(const uchar *buf, uint event_len,
/* if my_bitmap_init fails, caught in is_valid() */ /* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols, if (likely(!my_bitmap_init(&m_cols,
m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
m_width, m_width)))
false)))
{ {
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8); memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8);

View File

@ -5225,8 +5225,7 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
/* if my_bitmap_init fails, caught in is_valid() */ /* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols, if (likely(!my_bitmap_init(&m_cols,
m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
m_width, m_width)))
false)))
{ {
/* Cols can be zero if this is a dummy binrows event */ /* Cols can be zero if this is a dummy binrows event */
if (likely(cols != NULL)) if (likely(cols != NULL))
@ -8281,8 +8280,7 @@ void Update_rows_log_event::init(MY_BITMAP const *cols)
/* if my_bitmap_init fails, caught in is_valid() */ /* if my_bitmap_init fails, caught in is_valid() */
if (likely(!my_bitmap_init(&m_cols_ai, if (likely(!my_bitmap_init(&m_cols_ai,
m_width <= sizeof(m_bitbuf_ai)*8 ? m_bitbuf_ai : NULL, m_width <= sizeof(m_bitbuf_ai)*8 ? m_bitbuf_ai : NULL,
m_width, m_width)))
false)))
{ {
/* Cols can be zero if this is a dummy binrows event */ /* Cols can be zero if this is a dummy binrows event */
if (likely(cols != NULL)) if (likely(cols != NULL))

View File

@ -642,7 +642,23 @@ struct system_variables max_system_variables;
struct system_status_var global_status_var; struct system_status_var global_status_var;
MY_TMPDIR mysql_tmpdir_list; MY_TMPDIR mysql_tmpdir_list;
MY_BITMAP temp_pool; static MY_BITMAP temp_pool;
static mysql_mutex_t LOCK_temp_pool;
void temp_pool_clear_bit(uint bit)
{
mysql_mutex_lock(&LOCK_temp_pool);
bitmap_clear_bit(&temp_pool, bit);
mysql_mutex_unlock(&LOCK_temp_pool);
}
uint temp_pool_set_next()
{
mysql_mutex_lock(&LOCK_temp_pool);
uint res= bitmap_set_next(&temp_pool);
mysql_mutex_unlock(&LOCK_temp_pool);
return res;
}
CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *system_charset_info, *files_charset_info ;
CHARSET_INFO *national_charset_info, *table_alias_charset; CHARSET_INFO *national_charset_info, *table_alias_charset;
@ -889,7 +905,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
key_LOCK_manager, key_LOCK_backup_log, key_LOCK_manager, key_LOCK_backup_log,
key_LOCK_prepared_stmt_count, key_LOCK_prepared_stmt_count,
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_rpl_status, key_LOCK_server_started,
key_LOCK_status, key_LOCK_status, key_LOCK_temp_pool,
key_LOCK_system_variables_hash, key_LOCK_thd_data, key_LOCK_thd_kill, key_LOCK_system_variables_hash, key_LOCK_thd_data, key_LOCK_thd_kill,
key_LOCK_user_conn, key_LOCK_uuid_short_generator, key_LOG_LOCK_log, key_LOCK_user_conn, key_LOCK_uuid_short_generator, key_LOG_LOCK_log,
key_master_info_data_lock, key_master_info_run_lock, key_master_info_data_lock, key_master_info_run_lock,
@ -947,6 +963,7 @@ static PSI_mutex_info all_server_mutexes[]=
{ &key_hash_filo_lock, "hash_filo::lock", 0}, { &key_hash_filo_lock, "hash_filo::lock", 0},
{ &key_LOCK_active_mi, "LOCK_active_mi", PSI_FLAG_GLOBAL}, { &key_LOCK_active_mi, "LOCK_active_mi", PSI_FLAG_GLOBAL},
{ &key_LOCK_backup_log, "LOCK_backup_log", PSI_FLAG_GLOBAL}, { &key_LOCK_backup_log, "LOCK_backup_log", PSI_FLAG_GLOBAL},
{ &key_LOCK_temp_pool, "LOCK_temp_pool", PSI_FLAG_GLOBAL},
{ &key_LOCK_thread_id, "LOCK_thread_id", PSI_FLAG_GLOBAL}, { &key_LOCK_thread_id, "LOCK_thread_id", PSI_FLAG_GLOBAL},
{ &key_LOCK_crypt, "LOCK_crypt", PSI_FLAG_GLOBAL}, { &key_LOCK_crypt, "LOCK_crypt", PSI_FLAG_GLOBAL},
{ &key_LOCK_delayed_create, "LOCK_delayed_create", PSI_FLAG_GLOBAL}, { &key_LOCK_delayed_create, "LOCK_delayed_create", PSI_FLAG_GLOBAL},
@ -2053,6 +2070,7 @@ static void clean_up_mutexes()
mysql_mutex_destroy(&LOCK_active_mi); mysql_mutex_destroy(&LOCK_active_mi);
mysql_rwlock_destroy(&LOCK_ssl_refresh); mysql_rwlock_destroy(&LOCK_ssl_refresh);
mysql_mutex_destroy(&LOCK_backup_log); mysql_mutex_destroy(&LOCK_backup_log);
mysql_mutex_destroy(&LOCK_temp_pool);
mysql_rwlock_destroy(&LOCK_sys_init_connect); mysql_rwlock_destroy(&LOCK_sys_init_connect);
mysql_rwlock_destroy(&LOCK_sys_init_slave); mysql_rwlock_destroy(&LOCK_sys_init_slave);
mysql_mutex_destroy(&LOCK_global_system_variables); mysql_mutex_destroy(&LOCK_global_system_variables);
@ -4230,7 +4248,7 @@ static int init_common_variables()
#endif /* defined(ENABLED_DEBUG_SYNC) */ #endif /* defined(ENABLED_DEBUG_SYNC) */
#if (ENABLE_TEMP_POOL) #if (ENABLE_TEMP_POOL)
if (use_temp_pool && my_bitmap_init(&temp_pool,0,1024,1)) if (use_temp_pool && my_bitmap_init(&temp_pool,0,1024))
return 1; return 1;
#else #else
use_temp_pool= 0; use_temp_pool= 0;
@ -4357,6 +4375,7 @@ static int init_thread_environment()
mysql_mutex_init(key_LOCK_commit_ordered, &LOCK_commit_ordered, mysql_mutex_init(key_LOCK_commit_ordered, &LOCK_commit_ordered,
MY_MUTEX_INIT_SLOW); MY_MUTEX_INIT_SLOW);
mysql_mutex_init(key_LOCK_backup_log, &LOCK_backup_log, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_backup_log, &LOCK_backup_log, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_temp_pool, &LOCK_temp_pool, MY_MUTEX_INIT_FAST);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
mysql_mutex_init(key_LOCK_des_key_file, mysql_mutex_init(key_LOCK_des_key_file,

View File

@ -100,7 +100,9 @@ extern CHARSET_INFO *error_message_charset_info;
extern CHARSET_INFO *character_set_filesystem; extern CHARSET_INFO *character_set_filesystem;
extern MY_BITMAP temp_pool; void temp_pool_clear_bit(uint bit);
uint temp_pool_set_next();
extern bool opt_large_files; extern bool opt_large_files;
extern bool opt_update_log, opt_bin_log, opt_error_log, opt_bin_log_compress; extern bool opt_update_log, opt_bin_log, opt_error_log, opt_bin_log_compress;
extern uint opt_bin_log_compress_min_len; extern uint opt_bin_log_compress_min_len;

View File

@ -1308,7 +1308,7 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
*create_error= 1; *create_error= 1;
} }
else else
my_bitmap_init(&column_bitmap, bitmap, head->s->fields, FALSE); my_bitmap_init(&column_bitmap, bitmap, head->s->fields);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -2577,7 +2577,7 @@ static int fill_used_fields_bitmap(PARAM *param)
param->fields_bitmap_size= table->s->column_bitmap_size; param->fields_bitmap_size= table->s->column_bitmap_size;
if (!(tmp= (my_bitmap_map*) alloc_root(param->mem_root, if (!(tmp= (my_bitmap_map*) alloc_root(param->mem_root,
param->fields_bitmap_size)) || param->fields_bitmap_size)) ||
my_bitmap_init(&param->needed_fields, tmp, table->s->fields, FALSE)) my_bitmap_init(&param->needed_fields, tmp, table->s->fields))
return 1; return 1;
bitmap_copy(&param->needed_fields, table->read_set); bitmap_copy(&param->needed_fields, table->read_set);
@ -3347,7 +3347,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
my_bitmap_map* buf; my_bitmap_map* buf;
if (!(buf= (my_bitmap_map*)thd->alloc(table->s->column_bitmap_size))) if (!(buf= (my_bitmap_map*)thd->alloc(table->s->column_bitmap_size)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
my_bitmap_init(&handled_columns, buf, table->s->fields, FALSE); my_bitmap_init(&handled_columns, buf, table->s->fields);
/* /*
Calculate the selectivity of the range conditions supported by indexes. Calculate the selectivity of the range conditions supported by indexes.
@ -4137,7 +4137,7 @@ static int find_used_partitions_imerge_list(PART_PRUNE_PARAM *ppar,
*/ */
return find_used_partitions_imerge(ppar, merges.head()); return find_used_partitions_imerge(ppar, merges.head());
} }
my_bitmap_init(&all_merges, bitmap_buf, n_bits, FALSE); my_bitmap_init(&all_merges, bitmap_buf, n_bits);
bitmap_set_prefix(&all_merges, n_bits); bitmap_set_prefix(&all_merges, n_bits);
List_iterator<SEL_IMERGE> it(merges); List_iterator<SEL_IMERGE> it(merges);
@ -4793,8 +4793,7 @@ static bool create_partition_index_description(PART_PRUNE_PARAM *ppar)
uint32 bufsize= bitmap_buffer_size(ppar->part_info->num_subparts); uint32 bufsize= bitmap_buffer_size(ppar->part_info->num_subparts);
if (!(buf= (my_bitmap_map*) alloc_root(alloc, bufsize))) if (!(buf= (my_bitmap_map*) alloc_root(alloc, bufsize)))
return TRUE; return TRUE;
my_bitmap_init(&ppar->subparts_bitmap, buf, ppar->part_info->num_subparts, my_bitmap_init(&ppar->subparts_bitmap, buf, ppar->part_info->num_subparts);
FALSE);
} }
range_par->key_parts= key_part; range_par->key_parts= key_part;
Field **field= (ppar->part_fields)? part_info->part_field_array : Field **field= (ppar->part_fields)? part_info->part_field_array :
@ -5620,7 +5619,7 @@ bool create_fields_bitmap(PARAM *param, MY_BITMAP *fields_bitmap)
if (!(bitmap_buf= (my_bitmap_map *) alloc_root(param->mem_root, if (!(bitmap_buf= (my_bitmap_map *) alloc_root(param->mem_root,
param->fields_bitmap_size))) param->fields_bitmap_size)))
return TRUE; return TRUE;
if (my_bitmap_init(fields_bitmap, bitmap_buf, param->table->s->fields, FALSE)) if (my_bitmap_init(fields_bitmap, bitmap_buf, param->table->s->fields))
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -6532,7 +6531,7 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg)
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
if (my_bitmap_init(&ror_scan->covered_fields, bitmap_buf, if (my_bitmap_init(&ror_scan->covered_fields, bitmap_buf,
param->table->s->fields, FALSE)) param->table->s->fields))
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
bitmap_clear_all(&ror_scan->covered_fields); bitmap_clear_all(&ror_scan->covered_fields);
@ -6649,8 +6648,7 @@ ROR_INTERSECT_INFO* ror_intersect_init(const PARAM *param)
if (!(buf= (my_bitmap_map*) alloc_root(param->mem_root, if (!(buf= (my_bitmap_map*) alloc_root(param->mem_root,
param->fields_bitmap_size))) param->fields_bitmap_size)))
return NULL; return NULL;
if (my_bitmap_init(&info->covered_fields, buf, param->table->s->fields, if (my_bitmap_init(&info->covered_fields, buf, param->table->s->fields))
FALSE))
return NULL; return NULL;
info->is_covering= FALSE; info->is_covering= FALSE;
info->index_scan_costs= 0.0; info->index_scan_costs= 0.0;
@ -7295,7 +7293,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
param->fields_bitmap_size); param->fields_bitmap_size);
if (!covered_fields->bitmap || if (!covered_fields->bitmap ||
my_bitmap_init(covered_fields, covered_fields->bitmap, my_bitmap_init(covered_fields, covered_fields->bitmap,
param->table->s->fields, FALSE)) param->table->s->fields))
DBUG_RETURN(0); DBUG_RETURN(0);
bitmap_clear_all(covered_fields); bitmap_clear_all(covered_fields);

View File

@ -4476,7 +4476,7 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
STEP 1: Get temporary table name STEP 1: Get temporary table name
*/ */
if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES)) if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
temp_pool_slot = bitmap_lock_set_next(&temp_pool); temp_pool_slot = temp_pool_set_next();
if (temp_pool_slot != MY_BIT_NONE) // we got a slot if (temp_pool_slot != MY_BIT_NONE) // we got a slot
sprintf(path, "%s-subquery-%lx-%i", tmp_file_prefix, sprintf(path, "%s-subquery-%lx-%i", tmp_file_prefix,
@ -4513,7 +4513,7 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
NullS)) NullS))
{ {
if (temp_pool_slot != MY_BIT_NONE) if (temp_pool_slot != MY_BIT_NONE)
bitmap_lock_clear_bit(&temp_pool, temp_pool_slot); temp_pool_clear_bit(temp_pool_slot);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
strmov(tmpname,path); strmov(tmpname,path);
@ -4723,7 +4723,7 @@ err:
thd->mem_root= mem_root_save; thd->mem_root= mem_root_save;
free_tmp_table(thd,table); /* purecov: inspected */ free_tmp_table(thd,table); /* purecov: inspected */
if (temp_pool_slot != MY_BIT_NONE) if (temp_pool_slot != MY_BIT_NONE)
bitmap_lock_clear_bit(&temp_pool, temp_pool_slot); temp_pool_clear_bit(temp_pool_slot);
DBUG_RETURN(TRUE); /* purecov: inspected */ DBUG_RETURN(TRUE); /* purecov: inspected */
} }

View File

@ -1070,7 +1070,7 @@ bool Dep_analysis_context::setup_equality_modules_deps(List<Dep_module>
void *buf; void *buf;
if (!(buf= thd->alloc(bitmap_buffer_size(offset))) || if (!(buf= thd->alloc(bitmap_buffer_size(offset))) ||
my_bitmap_init(&expr_deps, (my_bitmap_map*)buf, offset, FALSE)) my_bitmap_init(&expr_deps, (my_bitmap_map*)buf, offset))
{ {
DBUG_RETURN(TRUE); /* purecov: inspected */ DBUG_RETURN(TRUE); /* purecov: inspected */
} }

View File

@ -788,7 +788,7 @@ bool init_slave_skip_errors(const char* arg)
if (!arg || !*arg) // No errors defined if (!arg || !*arg) // No errors defined
goto end; goto end;
if (unlikely(my_bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR,0))) if (my_bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR))
DBUG_RETURN(1); DBUG_RETURN(1);
use_slave_mask= 1; use_slave_mask= 1;

View File

@ -1402,7 +1402,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
DBUG_ASSERT(view->table != 0 && view->field_translation != 0); DBUG_ASSERT(view->table != 0 && view->field_translation != 0);
(void) my_bitmap_init(&used_fields, used_fields_buff, table->s->fields, 0); (void) my_bitmap_init(&used_fields, used_fields_buff, table->s->fields);
bitmap_clear_all(&used_fields); bitmap_clear_all(&used_fields);
view->contain_auto_increment= 0; view->contain_auto_increment= 0;
@ -2774,7 +2774,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
my_bitmap_init(&copy->has_value_set, my_bitmap_init(&copy->has_value_set,
(my_bitmap_map*) (bitmap + (my_bitmap_map*) (bitmap +
bitmaps_used*share->column_bitmap_size), bitmaps_used*share->column_bitmap_size),
share->fields, FALSE); share->fields);
} }
copy->tmp_set.bitmap= 0; // To catch errors copy->tmp_set.bitmap= 0; // To catch errors
bzero((char*) bitmap, share->column_bitmap_size * bitmaps_used); bzero((char*) bitmap, share->column_bitmap_size * bitmaps_used);

View File

@ -525,7 +525,7 @@ static bool create_full_part_field_array(THD *thd, TABLE *table,
goto end; goto end;
} }
if (unlikely(my_bitmap_init(&part_info->full_part_field_set, bitmap_buf, if (unlikely(my_bitmap_init(&part_info->full_part_field_set, bitmap_buf,
table->s->fields, FALSE))) table->s->fields)))
{ {
result= TRUE; result= TRUE;
goto end; goto end;
@ -1100,10 +1100,10 @@ static bool set_up_partition_bitmaps(THD *thd, partition_info *part_info)
bitmap_bytes * 2)))) bitmap_bytes * 2))))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
my_bitmap_init(&part_info->read_partitions, bitmap_buf, bitmap_bits, FALSE); my_bitmap_init(&part_info->read_partitions, bitmap_buf, bitmap_bits);
/* Use the second half of the allocated buffer for lock_partitions */ /* Use the second half of the allocated buffer for lock_partitions */
my_bitmap_init(&part_info->lock_partitions, bitmap_buf + (bitmap_bytes / 4), my_bitmap_init(&part_info->lock_partitions, bitmap_buf + (bitmap_bytes / 4),
bitmap_bits, FALSE); bitmap_bits);
part_info->bitmaps_are_initialized= TRUE; part_info->bitmaps_are_initialized= TRUE;
part_info->set_partition_bitmaps(NULL); part_info->set_partition_bitmaps(NULL);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);

View File

@ -18543,20 +18543,19 @@ setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps, uint field_count)
DBUG_ASSERT(table->s->virtual_fields == 0); DBUG_ASSERT(table->s->virtual_fields == 0);
my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count, my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count);
FALSE);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&table->tmp_set, my_bitmap_init(&table->tmp_set,
(my_bitmap_map*) bitmaps, field_count, FALSE); (my_bitmap_map*) bitmaps, field_count);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&table->eq_join_set, my_bitmap_init(&table->eq_join_set,
(my_bitmap_map*) bitmaps, field_count, FALSE); (my_bitmap_map*) bitmaps, field_count);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&table->cond_set, my_bitmap_init(&table->cond_set,
(my_bitmap_map*) bitmaps, field_count, FALSE); (my_bitmap_map*) bitmaps, field_count);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&table->has_value_set, my_bitmap_init(&table->has_value_set,
(my_bitmap_map*) bitmaps, field_count, FALSE); (my_bitmap_map*) bitmaps, field_count);
/* write_set and all_set are copies of read_set */ /* write_set and all_set are copies of read_set */
table->def_write_set= table->def_read_set; table->def_write_set= table->def_read_set;
table->s->all_set= table->def_read_set; table->s->all_set= table->def_read_set;
@ -18679,7 +18678,7 @@ TABLE *Create_tmp_table::start(THD *thd,
(ulong) m_rows_limit, MY_TEST(m_group))); (ulong) m_rows_limit, MY_TEST(m_group)));
if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES)) if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
m_temp_pool_slot = bitmap_lock_set_next(&temp_pool); m_temp_pool_slot = temp_pool_set_next();
if (m_temp_pool_slot != MY_BIT_NONE) // we got a slot if (m_temp_pool_slot != MY_BIT_NONE) // we got a slot
sprintf(path, "%s-%s-%lx-%i", tmp_file_prefix, param->tmp_name, sprintf(path, "%s-%s-%lx-%i", tmp_file_prefix, param->tmp_name,
@ -19589,7 +19588,7 @@ void Create_tmp_table::cleanup_on_failure(THD *thd, TABLE *table)
if (table) if (table)
free_tmp_table(thd, table); free_tmp_table(thd, table);
if (m_temp_pool_slot != MY_BIT_NONE) if (m_temp_pool_slot != MY_BIT_NONE)
bitmap_lock_clear_bit(&temp_pool, m_temp_pool_slot); temp_pool_clear_bit(m_temp_pool_slot);
} }
@ -20354,7 +20353,7 @@ free_tmp_table(THD *thd, TABLE *entry)
(*ptr)->free(); (*ptr)->free();
if (entry->temp_pool_slot != MY_BIT_NONE) if (entry->temp_pool_slot != MY_BIT_NONE)
bitmap_lock_clear_bit(&temp_pool, entry->temp_pool_slot); temp_pool_clear_bit(entry->temp_pool_slot);
plugin_unlock(0, entry->s->db_plugin); plugin_unlock(0, entry->s->db_plugin);
entry->alias.free(); entry->alias.free();

View File

@ -8217,8 +8217,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN(0); DBUG_RETURN(0);
my_bitmap_map* bitmaps= my_bitmap_map* bitmaps=
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count)); (my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count, my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count);
FALSE);
table->read_set= &table->def_read_set; table->read_set= &table->def_read_set;
bitmap_clear_all(table->read_set); bitmap_clear_all(table->read_set);
table_list->schema_table_param= tmp_table_param; table_list->schema_table_param= tmp_table_param;

View File

@ -271,7 +271,7 @@ static void prepare_record_for_error_message(int error, TABLE *table)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
/* Create unique_map with all fields used by that index. */ /* Create unique_map with all fields used by that index. */
my_bitmap_init(&unique_map, unique_map_buf, table->s->fields, FALSE); my_bitmap_init(&unique_map, unique_map_buf, table->s->fields);
table->mark_index_columns(keynr, &unique_map); table->mark_index_columns(keynr, &unique_map);
/* Subtract read_set and write_set. */ /* Subtract read_set and write_set. */

View File

@ -3329,7 +3329,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
share->column_bitmap_size * share->column_bitmap_size *
bitmap_count))) bitmap_count)))
goto err; goto err;
my_bitmap_init(&share->all_set, bitmaps, share->fields, FALSE); my_bitmap_init(&share->all_set, bitmaps, share->fields);
bitmap_set_all(&share->all_set); bitmap_set_all(&share->all_set);
if (share->check_set) if (share->check_set)
{ {
@ -3340,7 +3340,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
my_bitmap_init(share->check_set, my_bitmap_init(share->check_set,
(my_bitmap_map*) ((uchar*) bitmaps + (my_bitmap_map*) ((uchar*) bitmaps +
share->column_bitmap_size), share->column_bitmap_size),
share->fields, FALSE); share->fields);
bitmap_clear_all(share->check_set); bitmap_clear_all(share->check_set);
} }
@ -4292,26 +4292,26 @@ partititon_err:
goto err; goto err;
my_bitmap_init(&outparam->def_read_set, my_bitmap_init(&outparam->def_read_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&outparam->def_write_set, my_bitmap_init(&outparam->def_write_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&outparam->has_value_set, my_bitmap_init(&outparam->has_value_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&outparam->tmp_set, my_bitmap_init(&outparam->tmp_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&outparam->eq_join_set, my_bitmap_init(&outparam->eq_join_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&outparam->cond_set, my_bitmap_init(&outparam->cond_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
bitmaps+= bitmap_size; bitmaps+= bitmap_size;
my_bitmap_init(&outparam->def_rpl_write_set, my_bitmap_init(&outparam->def_rpl_write_set,
(my_bitmap_map*) bitmaps, share->fields, FALSE); (my_bitmap_map*) bitmaps, share->fields);
outparam->default_column_bitmaps(); outparam->default_column_bitmaps();
outparam->cond_selectivity= 1.0; outparam->cond_selectivity= 1.0;

View File

@ -156,8 +156,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
info.lock_type= F_WRLCK; info.lock_type= F_WRLCK;
_ma_set_data_pagecache_callbacks(&info.dfile, share); _ma_set_data_pagecache_callbacks(&info.dfile, share);
my_bitmap_init(&info.changed_fields, changed_fields_bitmap, my_bitmap_init(&info.changed_fields, changed_fields_bitmap, share->base.fields);
share->base.fields, 0);
if ((*share->init)(&info)) if ((*share->init)(&info))
goto err; goto err;

View File

@ -4926,7 +4926,7 @@ int ha_mroonga::open(const char *name,
DBUG_RETURN(error); DBUG_RETURN(error);
thr_lock_data_init(&share->lock,&thr_lock_data,NULL); thr_lock_data_init(&share->lock,&thr_lock_data,NULL);
if (bitmap_init(&multiple_column_key_bitmap, NULL, table->s->fields, false)) if (my_bitmap_init(&multiple_column_key_bitmap, NULL, table->s->fields))
{ {
mrn_free_share(share); mrn_free_share(share);
share = NULL; share = NULL;
@ -4942,7 +4942,7 @@ int ha_mroonga::open(const char *name,
if (error) if (error)
{ {
bitmap_free(&multiple_column_key_bitmap); my_bitmap_free(&multiple_column_key_bitmap);
mrn_free_share(share); mrn_free_share(share);
share = NULL; share = NULL;
} }
@ -5009,7 +5009,7 @@ int ha_mroonga::close()
{ {
error = add_wrap_hton(share->table_name, share->hton); error = add_wrap_hton(share->table_name, share->hton);
} }
bitmap_free(&multiple_column_key_bitmap); my_bitmap_free(&multiple_column_key_bitmap);
if (share->use_count == 1) { if (share->use_count == 1) {
mrn_free_long_term_share(share->long_term_share); mrn_free_long_term_share(share->long_term_share);
} }

View File

@ -26,7 +26,7 @@ namespace mrn {
SmartBitmap::~SmartBitmap() { SmartBitmap::~SmartBitmap() {
if (bitmap_) { if (bitmap_) {
bitmap_free(bitmap_); my_bitmap_free(bitmap_);
} }
} }

View File

@ -10786,7 +10786,7 @@ int ha_rocksdb::index_end() {
release_scan_iterator(); release_scan_iterator();
bitmap_free(&m_lookup_bitmap); my_bitmap_free(&m_lookup_bitmap);
active_index = MAX_KEY; active_index = MAX_KEY;
in_range_check_pushed_down = FALSE; in_range_check_pushed_down = FALSE;

View File

@ -397,7 +397,7 @@ class ha_rocksdb : public my_core::handler {
current lookup to be covered. If the bitmap field is null, that means this current lookup to be covered. If the bitmap field is null, that means this
index does not cover the current lookup for any record. index does not cover the current lookup for any record.
*/ */
MY_BITMAP m_lookup_bitmap = {nullptr, nullptr, nullptr, 0, 0}; MY_BITMAP m_lookup_bitmap = {nullptr, nullptr, 0, 0};
int alloc_key_buffers(const TABLE *const table_arg, int alloc_key_buffers(const TABLE *const table_arg,
const Rdb_tbl_def *const tbl_def_arg, const Rdb_tbl_def *const tbl_def_arg,

View File

@ -1102,12 +1102,12 @@ size_t Rdb_key_def::get_unpack_header_size(char tag) {
*/ */
void Rdb_key_def::get_lookup_bitmap(const TABLE *table, MY_BITMAP *map) const { void Rdb_key_def::get_lookup_bitmap(const TABLE *table, MY_BITMAP *map) const {
DBUG_ASSERT(map->bitmap == nullptr); DBUG_ASSERT(map->bitmap == nullptr);
bitmap_init(map, nullptr, MAX_REF_PARTS, false); my_bitmap_init(map, nullptr, MAX_REF_PARTS);
uint curr_bitmap_pos = 0; uint curr_bitmap_pos = 0;
// Indicates which columns in the read set might be covered. // Indicates which columns in the read set might be covered.
MY_BITMAP maybe_covered_bitmap; MY_BITMAP maybe_covered_bitmap;
bitmap_init(&maybe_covered_bitmap, nullptr, table->read_set->n_bits, false); my_bitmap_init(&maybe_covered_bitmap, nullptr, table->read_set->n_bits);
for (uint i = 0; i < m_key_parts; i++) { for (uint i = 0; i < m_key_parts; i++) {
if (table_has_hidden_pk(table) && i + 1 == m_key_parts) { if (table_has_hidden_pk(table) && i + 1 == m_key_parts) {
@ -1135,8 +1135,8 @@ void Rdb_key_def::get_lookup_bitmap(const TABLE *table, MY_BITMAP *map) const {
} }
curr_bitmap_pos++; curr_bitmap_pos++;
} else { } else {
bitmap_free(&maybe_covered_bitmap); my_bitmap_free(&maybe_covered_bitmap);
bitmap_free(map); my_bitmap_free(map);
return; return;
} }
break; break;
@ -1144,8 +1144,8 @@ void Rdb_key_def::get_lookup_bitmap(const TABLE *table, MY_BITMAP *map) const {
// know this lookup will never be covered. // know this lookup will never be covered.
default: default:
if (bitmap_is_set(table->read_set, field->field_index)) { if (bitmap_is_set(table->read_set, field->field_index)) {
bitmap_free(&maybe_covered_bitmap); my_bitmap_free(&maybe_covered_bitmap);
bitmap_free(map); my_bitmap_free(map);
return; return;
} }
break; break;
@ -1155,9 +1155,9 @@ void Rdb_key_def::get_lookup_bitmap(const TABLE *table, MY_BITMAP *map) const {
// If there are columns which are not covered in the read set, the lookup // If there are columns which are not covered in the read set, the lookup
// can't be covered. // can't be covered.
if (!bitmap_cmp(table->read_set, &maybe_covered_bitmap)) { if (!bitmap_cmp(table->read_set, &maybe_covered_bitmap)) {
bitmap_free(map); my_bitmap_free(map);
} }
bitmap_free(&maybe_covered_bitmap); my_bitmap_free(&maybe_covered_bitmap);
} }
/* /*
@ -1187,7 +1187,7 @@ bool Rdb_key_def::covers_lookup(const rocksdb::Slice *const unpack_info,
MY_BITMAP covered_bitmap; MY_BITMAP covered_bitmap;
my_bitmap_map covered_bits; my_bitmap_map covered_bits;
bitmap_init(&covered_bitmap, &covered_bits, MAX_REF_PARTS, false); my_bitmap_init(&covered_bitmap, &covered_bits, MAX_REF_PARTS);
covered_bits = rdb_netbuf_to_uint16((const uchar *)unpack_header + covered_bits = rdb_netbuf_to_uint16((const uchar *)unpack_header +
sizeof(RDB_UNPACK_COVERED_DATA_TAG) + sizeof(RDB_UNPACK_COVERED_DATA_TAG) +
RDB_UNPACK_COVERED_DATA_LEN_SIZE); RDB_UNPACK_COVERED_DATA_LEN_SIZE);
@ -1356,7 +1356,7 @@ uint Rdb_key_def::pack_record(const TABLE *const tbl, uchar *const pack_buffer,
MY_BITMAP covered_bitmap; MY_BITMAP covered_bitmap;
my_bitmap_map covered_bits; my_bitmap_map covered_bits;
uint curr_bitmap_pos = 0; uint curr_bitmap_pos = 0;
bitmap_init(&covered_bitmap, &covered_bits, MAX_REF_PARTS, false); my_bitmap_init(&covered_bitmap, &covered_bits, MAX_REF_PARTS);
for (uint i = 0; i < n_key_parts; i++) { for (uint i = 0; i < n_key_parts; i++) {
// Fill hidden pk id into the last key part for secondary keys for tables // Fill hidden pk id into the last key part for secondary keys for tables
@ -1661,7 +1661,7 @@ int Rdb_key_def::unpack_record(TABLE *const table, uchar *const buf,
bool has_covered_bitmap = bool has_covered_bitmap =
has_unpack_info && (unpack_header[0] == RDB_UNPACK_COVERED_DATA_TAG); has_unpack_info && (unpack_header[0] == RDB_UNPACK_COVERED_DATA_TAG);
if (has_covered_bitmap) { if (has_covered_bitmap) {
bitmap_init(&covered_bitmap, &covered_bits, MAX_REF_PARTS, false); my_bitmap_init(&covered_bitmap, &covered_bits, MAX_REF_PARTS);
covered_bits = rdb_netbuf_to_uint16((const uchar *)unpack_header + covered_bits = rdb_netbuf_to_uint16((const uchar *)unpack_header +
sizeof(RDB_UNPACK_COVERED_DATA_TAG) + sizeof(RDB_UNPACK_COVERED_DATA_TAG) +
RDB_UNPACK_COVERED_DATA_LEN_SIZE); RDB_UNPACK_COVERED_DATA_LEN_SIZE);

View File

@ -129,8 +129,8 @@ my_bool test_compare_operators(MY_BITMAP *map, uint bitsize)
MY_BITMAP *map2= &map2_obj, *map3= &map3_obj; MY_BITMAP *map2= &map2_obj, *map3= &map3_obj;
my_bitmap_map map2buf[MAX_TESTED_BITMAP_SIZE]; my_bitmap_map map2buf[MAX_TESTED_BITMAP_SIZE];
my_bitmap_map map3buf[MAX_TESTED_BITMAP_SIZE]; my_bitmap_map map3buf[MAX_TESTED_BITMAP_SIZE];
my_bitmap_init(&map2_obj, map2buf, bitsize, FALSE); my_bitmap_init(&map2_obj, map2buf, bitsize);
my_bitmap_init(&map3_obj, map3buf, bitsize, FALSE); my_bitmap_init(&map3_obj, map3buf, bitsize);
bitmap_clear_all(map2); bitmap_clear_all(map2);
bitmap_clear_all(map3); bitmap_clear_all(map3);
for (i=0; i < no_loops; i++) for (i=0; i < no_loops; i++)
@ -374,7 +374,7 @@ my_bool test_compare(MY_BITMAP *map, uint bitsize)
uint32 map2buf[MAX_TESTED_BITMAP_SIZE]; uint32 map2buf[MAX_TESTED_BITMAP_SIZE];
uint i, test_bit; uint i, test_bit;
uint no_loops= bitsize > 128 ? 128 : bitsize; uint no_loops= bitsize > 128 ? 128 : bitsize;
if (my_bitmap_init(&map2, map2buf, bitsize, FALSE)) if (my_bitmap_init(&map2, map2buf, bitsize))
{ {
diag("init error for bitsize %d", bitsize); diag("init error for bitsize %d", bitsize);
return TRUE; return TRUE;
@ -433,7 +433,7 @@ my_bool test_intersect(MY_BITMAP *map, uint bitsize)
MY_BITMAP map2; MY_BITMAP map2;
uint32 map2buf[MAX_TESTED_BITMAP_SIZE]; uint32 map2buf[MAX_TESTED_BITMAP_SIZE];
uint i, test_bit1, test_bit2, test_bit3; uint i, test_bit1, test_bit2, test_bit3;
if (my_bitmap_init(&map2, map2buf, bitsize2, FALSE)) if (my_bitmap_init(&map2, map2buf, bitsize2))
{ {
diag("init error for bitsize %d", bitsize2); diag("init error for bitsize %d", bitsize2);
return TRUE; return TRUE;
@ -481,7 +481,7 @@ my_bool do_test(uint bitsize)
{ {
MY_BITMAP map; MY_BITMAP map;
my_bitmap_map buf[MAX_TESTED_BITMAP_SIZE]; my_bitmap_map buf[MAX_TESTED_BITMAP_SIZE];
if (my_bitmap_init(&map, buf, bitsize, FALSE)) if (my_bitmap_init(&map, buf, bitsize))
{ {
diag("init error for bitsize %d", bitsize); diag("init error for bitsize %d", bitsize);
goto error; goto error;