Commit 5985904e authored by unknown's avatar unknown

Many fixes

parent f8b75e07
...@@ -21,10 +21,13 @@ ...@@ -21,10 +21,13 @@
#define MY_BIT_NONE (~(uint) 0) #define MY_BIT_NONE (~(uint) 0)
typedef struct st_bitmap typedef struct st_bitmap
{ {
uchar *bitmap; uchar *bitmap;
uint bitmap_size; /* number of bytes occupied by the above */ uint bitmap_size; /* number of bits occupied by the above */
uint32 last_word_mask;
uint32 *last_word_ptr;
/* /*
mutex will be acquired for the duration of each bitmap operation if 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 thread_safe flag in bitmap_init was set. Otherwise, we optimize by not
...@@ -38,30 +41,60 @@ typedef struct st_bitmap ...@@ -38,30 +41,60 @@ typedef struct st_bitmap
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2);
extern my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, my_bool thread_safe); extern my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, 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(const MY_BITMAP *map, uint bitmap_bit);
extern my_bool bitmap_is_set_all(const MY_BITMAP *map); extern my_bool bitmap_is_set_all(const MY_BITMAP *map);
extern my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2); extern my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2);
extern uint bitmap_set_next(MY_BITMAP *map); extern uint bitmap_set_next(MY_BITMAP *map);
extern uint bitmap_get_first(const MY_BITMAP *map); extern uint bitmap_get_first(const MY_BITMAP *map);
extern uint bitmap_get_first_set(const MY_BITMAP *map);
extern uint bitmap_bits_set(const MY_BITMAP *map); extern uint bitmap_bits_set(const MY_BITMAP *map);
extern void bitmap_clear_all(MY_BITMAP *map);
extern void bitmap_clear_bit(MY_BITMAP *map, uint bitmap_bit);
extern void bitmap_free(MY_BITMAP *map); extern void bitmap_free(MY_BITMAP *map);
extern void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_set_all(MY_BITMAP *map);
extern void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit);
extern void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size); extern void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size);
extern void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2); extern void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2); extern void bitmap_union(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);
#ifdef NOT_USED
extern uint bitmap_lock_bits_set(const MY_BITMAP *map);
extern my_bool bitmap_lock_is_set_all(const MY_BITMAP *map);
extern uint bitmap_lock_get_first(const MY_BITMAP *map);
extern uint bitmap_lock_get_first_set(const MY_BITMAP *map);
extern my_bool bitmap_lock_is_subset(const MY_BITMAP *map1,
const MY_BITMAP *map2);
extern my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size);
extern my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit);
extern my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map);
extern my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2);
extern void bitmap_lock_set_all(MY_BITMAP *map);
extern void bitmap_lock_clear_all(MY_BITMAP *map);
extern void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit);
extern void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit);
extern void bitmap_lock_set_prefix(MY_BITMAP *map, uint prefix_size);
extern void bitmap_lock_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_lock_subtract(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_lock_union(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_lock_xor(MY_BITMAP *map, const MY_BITMAP *map2);
extern void bitmap_lock_invert(MY_BITMAP *map);
#endif
/* Fast, not thread safe, bitmap functions */ /* Fast, not thread safe, bitmap functions */
#define bitmap_fast_set_bit(MAP, BIT) (MAP)->bitmap[(BIT) / 8] |= (1 << ((BIT) & 7)) #define no_bytes_in_map(map) ((map->bitmap_size + 7)/8)
#define bitmap_fast_clear_bit(MAP, BIT) (MAP)->bitmap[(BIT) / 8] &= ~ (1 << ((BIT) & 7)) #define no_words_in_map(map) ((map->bitmap_size + 31)/32)
#define bitmap_fast_is_set(MAP, BIT) (MAP)->bitmap[(BIT) / 8] & (1 << ((BIT) & 7)) #define bytes_word_aligned(bytes) (4*((bytes + 3)/4))
#define bitmap_set_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] |= (1 << ((BIT) & 7)))
#define bitmap_flip_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] ^= (1 << ((BIT) & 7)))
#define bitmap_clear_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] &= ~ (1 << ((BIT) & 7)))
#define bitmap_is_set(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] & (1 << ((BIT) & 7)))
#define bitmap_cmp(MAP1, MAP2) \
(memcmp((MAP1)->bitmap, (MAP2)->bitmap, 4*no_words_in_map((MAP1)))==0)
#define bitmap_clear_all(MAP) \
memset((MAP)->bitmap, 0, 4*no_words_in_map((MAP))); \
*(MAP)->last_word_ptr|= (MAP)->last_word_mask
#define bitmap_set_all(MAP) \
(memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP))))
#ifdef __cplusplus #ifdef __cplusplus
} }
......
This diff is collapsed.
...@@ -1357,16 +1357,17 @@ int handler::ha_initialise() ...@@ -1357,16 +1357,17 @@ int handler::ha_initialise()
int handler::ha_allocate_read_write_set(ulong no_fields) int handler::ha_allocate_read_write_set(ulong no_fields)
{ {
uint bitmap_size= 4*(((no_fields+1)+31)/32);
uchar *read_buf, *write_buf;
DBUG_ENTER("ha_allocate_read_write_set"); DBUG_ENTER("ha_allocate_read_write_set");
DBUG_PRINT("info", ("no_fields = %d", no_fields)); DBUG_PRINT("info", ("no_fields = %d", no_fields));
read_set= new bitvector; read_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP));
write_set= new bitvector; write_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP));
if (!read_set || !write_set) read_buf= (uchar*)sql_alloc(bitmap_size);
{ write_buf= (uchar*)sql_alloc(bitmap_size);
ha_deallocate_read_write_set(); DBUG_ASSERT(!bitmap_init(read_set, read_buf, (no_fields+1), FALSE));
DBUG_RETURN(TRUE); DBUG_ASSERT(!bitmap_init(write_set, write_buf, (no_fields+1), FALSE));
} if (!read_set || !write_set || !read_buf || !write_buf)
if (read_set->init(no_fields+1) || write_set->init(no_fields+1))
{ {
ha_deallocate_read_write_set(); ha_deallocate_read_write_set();
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
...@@ -1378,8 +1379,6 @@ int handler::ha_allocate_read_write_set(ulong no_fields) ...@@ -1378,8 +1379,6 @@ int handler::ha_allocate_read_write_set(ulong no_fields)
void handler::ha_deallocate_read_write_set() void handler::ha_deallocate_read_write_set()
{ {
DBUG_ENTER("ha_deallocate_read_write_set"); DBUG_ENTER("ha_deallocate_read_write_set");
delete read_set;
delete write_set;
read_set=write_set=0; read_set=write_set=0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1387,127 +1386,17 @@ void handler::ha_deallocate_read_write_set() ...@@ -1387,127 +1386,17 @@ void handler::ha_deallocate_read_write_set()
void handler::ha_clear_all_set() void handler::ha_clear_all_set()
{ {
DBUG_ENTER("ha_clear_all_set"); DBUG_ENTER("ha_clear_all_set");
read_set->clear_all(); bitmap_clear_all(read_set);
write_set->clear_all(); bitmap_clear_all(write_set);
read_set->set_bit((uint)0); bitmap_set_bit(read_set, 0);
write_set->set_bit((uint)0); bitmap_set_bit(write_set, 0);
DBUG_VOID_RETURN;
}
void handler::ha_set_all_bits_in_read_set()
{
DBUG_ENTER("ha_set_all_bits_in_read_set");
read_set->set_all();
DBUG_VOID_RETURN;
}
void handler::ha_set_all_bits_in_write_set()
{
DBUG_ENTER("ha_set_all_bits_in_write_set");
write_set->set_all();
DBUG_VOID_RETURN;
}
void handler::ha_set_bit_in_read_set(uint fieldnr)
{
DBUG_ENTER("ha_set_bit_in_read_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
read_set->set_bit((size_t)fieldnr);
DBUG_VOID_RETURN;
}
void handler::ha_clear_bit_in_read_set(uint fieldnr)
{
DBUG_ENTER("ha_clear_bit_in_read_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
read_set->clear_bit((size_t)fieldnr);
DBUG_VOID_RETURN;
}
void handler::ha_set_bit_in_write_set(uint fieldnr)
{
DBUG_ENTER("ha_set_bit_in_write_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
write_set->set_bit((size_t)fieldnr);
DBUG_VOID_RETURN;
}
void handler::ha_clear_bit_in_write_set(uint fieldnr)
{
DBUG_ENTER("ha_clear_bit_in_write_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
write_set->clear_bit((size_t)fieldnr);
DBUG_VOID_RETURN;
}
void handler::ha_set_bit_in_rw_set(uint fieldnr, bool write_op)
{
DBUG_ENTER("ha_set_bit_in_rw_set");
if (!write_op) {
DBUG_PRINT("info", ("Set bit %u in read set", fieldnr));
read_set->set_bit((size_t)fieldnr);
}
else
{
DBUG_PRINT("info", ("Set bit %u in read and write set", fieldnr));
read_set->set_bit((size_t)fieldnr);
write_set->set_bit((size_t)fieldnr);
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
bool handler::ha_get_bit_in_read_set(uint fieldnr)
{
bool bit_set=read_set->get_bit((size_t)fieldnr);
DBUG_ENTER("ha_get_bit_in_read_set");
DBUG_PRINT("info", ("bit %u = %u", fieldnr, bit_set));
DBUG_RETURN(bit_set);
}
bool handler::ha_get_bit_in_write_set(uint fieldnr)
{
bool bit_set=write_set->get_bit((size_t)fieldnr);
DBUG_ENTER("ha_get_bit_in_write_set");
DBUG_PRINT("info", ("bit %u = %u", fieldnr, bit_set));
DBUG_RETURN(bit_set);
}
bool handler::ha_get_all_bit_in_read_set()
{
bool bit_set=read_set->get_all_bits_set();
DBUG_ENTER("ha_get_all_bit_in_read_set");
DBUG_PRINT("info", ("all bits set = %u", bit_set));
DBUG_RETURN(bit_set);
}
bool handler::ha_get_all_bit_in_read_clear()
{
bool bit_set=read_set->get_all_bits_clear();
DBUG_ENTER("ha_get_all_bit_in_read_clear");
DBUG_PRINT("info", ("all bits clear = %u", bit_set));
DBUG_RETURN(bit_set);
}
bool handler::ha_get_all_bit_in_write_set()
{
bool bit_set=write_set->get_all_bits_set();
DBUG_ENTER("ha_get_all_bit_in_write_set");
DBUG_PRINT("info", ("all bits set = %u", bit_set));
DBUG_RETURN(bit_set);
}
bool handler::ha_get_all_bit_in_write_clear()
{
bool bit_set=write_set->get_all_bits_clear();
DBUG_ENTER("ha_get_all_bit_in_write_clear");
DBUG_PRINT("info", ("all bits clear = %u", bit_set));
DBUG_RETURN(bit_set);
}
int handler::ha_retrieve_all_cols() int handler::ha_retrieve_all_cols()
{ {
DBUG_ENTER("handler::ha_retrieve_all_cols"); DBUG_ENTER("handler::ha_retrieve_all_cols");
read_set->set_all(); bitmap_set_all(read_set);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -486,8 +486,8 @@ public: ...@@ -486,8 +486,8 @@ public:
bool auto_increment_column_changed; bool auto_increment_column_changed;
bool implicit_emptied; /* Can be !=0 only if HEAP */ bool implicit_emptied; /* Can be !=0 only if HEAP */
const COND *pushed_cond; const COND *pushed_cond;
bitvector *read_set; MY_BITMAP *read_set;
bitvector *write_set; MY_BITMAP *write_set;
handler(TABLE *table_arg) :table(table_arg), handler(TABLE *table_arg) :table(table_arg),
ref(0), data_file_length(0), max_data_file_length(0), index_file_length(0), ref(0), data_file_length(0), max_data_file_length(0), index_file_length(0),
...@@ -497,7 +497,7 @@ public: ...@@ -497,7 +497,7 @@ public:
key_used_on_scan(MAX_KEY), active_index(MAX_KEY), key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
ref_length(sizeof(my_off_t)), block_size(0), ref_length(sizeof(my_off_t)), block_size(0),
raid_type(0), ft_handler(0), inited(NONE), implicit_emptied(0), raid_type(0), ft_handler(0), inited(NONE), implicit_emptied(0),
pushed_cond(NULL), read_set(0), write_set(0) pushed_cond(NULL)
{} {}
virtual ~handler(void) virtual ~handler(void)
{ {
...@@ -597,24 +597,107 @@ public: ...@@ -597,24 +597,107 @@ public:
*/ */
virtual int ha_retrieve_all_cols(); virtual int ha_retrieve_all_cols();
virtual int ha_retrieve_all_pk(); virtual int ha_retrieve_all_pk();
void ha_set_all_bits_in_read_set(); void ha_set_all_bits_in_read_set()
void ha_set_all_bits_in_write_set(); {
void ha_set_bit_in_read_set(uint fieldnr); DBUG_ENTER("ha_set_all_bits_in_read_set");
void ha_clear_bit_in_read_set(uint fieldnr); bitmap_set_all(read_set);
void ha_set_bit_in_write_set(uint fieldnr); DBUG_VOID_RETURN;
void ha_clear_bit_in_write_set(uint fieldnr); }
void ha_set_bit_in_rw_set(uint fieldnr, bool write_set); void ha_set_all_bits_in_write_set()
bool ha_get_bit_in_read_set(uint fieldnr); {
bool ha_get_bit_in_write_set(uint fieldnr); DBUG_ENTER("ha_set_all_bits_in_write_set");
bool ha_get_all_bit_in_read_set(); bitmap_set_all(write_set);
bool ha_get_all_bit_in_read_clear(); DBUG_VOID_RETURN;
bool ha_get_all_bit_in_write_set(); }
bool ha_get_all_bit_in_write_clear(); void ha_set_bit_in_read_set(uint fieldnr)
{
DBUG_ENTER("ha_set_bit_in_read_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
bitmap_set_bit(read_set, fieldnr);
DBUG_VOID_RETURN;
}
void ha_clear_bit_in_read_set(uint fieldnr)
{
DBUG_ENTER("ha_clear_bit_in_read_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
bitmap_clear_bit(read_set, fieldnr);
DBUG_VOID_RETURN;
}
void ha_set_bit_in_write_set(uint fieldnr)
{
DBUG_ENTER("ha_set_bit_in_write_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
bitmap_set_bit(write_set, fieldnr);
DBUG_VOID_RETURN;
}
void ha_clear_bit_in_write_set(uint fieldnr)
{
DBUG_ENTER("ha_clear_bit_in_write_set");
DBUG_PRINT("info", ("fieldnr = %d", fieldnr));
bitmap_clear_bit(write_set, fieldnr);
DBUG_VOID_RETURN;
}
void ha_set_bit_in_rw_set(uint fieldnr, bool write_op)
{
DBUG_ENTER("ha_set_bit_in_rw_set");
DBUG_PRINT("info", ("Set bit %u in read set", fieldnr));
bitmap_set_bit(read_set, fieldnr);
if (!write_op) {
DBUG_VOID_RETURN;
}
else
{
DBUG_PRINT("info", ("Set bit %u in read and write set", fieldnr));
bitmap_set_bit(write_set, fieldnr);
}
DBUG_VOID_RETURN;
}
bool ha_get_bit_in_read_set(uint fieldnr)
{
bool bit_set=bitmap_is_set(read_set,fieldnr);
DBUG_ENTER("ha_get_bit_in_read_set");
DBUG_PRINT("info", ("bit %u = %u", fieldnr, bit_set));
DBUG_RETURN(bit_set);
}
bool ha_get_bit_in_write_set(uint fieldnr)
{
bool bit_set=bitmap_is_set(write_set,fieldnr);
DBUG_ENTER("ha_get_bit_in_write_set");
DBUG_PRINT("info", ("bit %u = %u", fieldnr, bit_set));
DBUG_RETURN(bit_set);
}
bool ha_get_all_bit_in_read_set()
{
bool all_bits_set= bitmap_is_set_all(read_set);
DBUG_ENTER("ha_get_all_bit_in_read_set");
DBUG_PRINT("info", ("all bits set = %u", all_bits_set));
DBUG_RETURN(all_bits_set);
}
bool ha_get_all_bit_in_read_clear()
{
bool all_bits_set= bitmap_is_clear_all(read_set);
DBUG_ENTER("ha_get_all_bit_in_read_clear");
DBUG_PRINT("info", ("all bits clear = %u", all_bits_set));
DBUG_RETURN(all_bits_set);
}
bool ha_get_all_bit_in_write_set()
{
bool all_bits_set= bitmap_is_set_all(write_set);
DBUG_ENTER("ha_get_all_bit_in_write_set");
DBUG_PRINT("info", ("all bits set = %u", all_bits_set));
DBUG_RETURN(all_bits_set);
}
bool ha_get_all_bit_in_write_clear()
{
bool all_bits_set= bitmap_is_clear_all(write_set);
DBUG_ENTER("ha_get_all_bit_in_write_clear");
DBUG_PRINT("info", ("all bits clear = %u", all_bits_set));
DBUG_RETURN(all_bits_set);
}
void ha_set_primary_key_in_read_set(); void ha_set_primary_key_in_read_set();
int ha_allocate_read_write_set(ulong no_fields); int ha_allocate_read_write_set(ulong no_fields);
void ha_deallocate_read_write_set(); void ha_deallocate_read_write_set();
void ha_clear_all_set(); void ha_clear_all_set();
uint get_index(void) const { return active_index; } uint get_index(void) const { return active_index; }
virtual int open(const char *name, int mode, uint test_if_locked)=0; virtual int open(const char *name, int mode, uint test_if_locked)=0;
virtual int close(void)=0; virtual int close(void)=0;
......
...@@ -1566,7 +1566,8 @@ static int fill_used_fields_bitmap(PARAM *param) ...@@ -1566,7 +1566,8 @@ static int fill_used_fields_bitmap(PARAM *param)
param->fields_bitmap_size= (table->s->fields/8 + 1); param->fields_bitmap_size= (table->s->fields/8 + 1);
uchar *tmp; uchar *tmp;
uint pk; uint pk;
if (!(tmp= (uchar*)alloc_root(param->mem_root,param->fields_bitmap_size)) || if (!(tmp= (uchar*)alloc_root(param->mem_root,
bytes_word_aligned(param->fields_bitmap_size))) ||
bitmap_init(&param->needed_fields, tmp, param->fields_bitmap_size*8, bitmap_init(&param->needed_fields, tmp, param->fields_bitmap_size*8,
FALSE)) FALSE))
return 1; return 1;
...@@ -2321,7 +2322,7 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg) ...@@ -2321,7 +2322,7 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg)
ror_scan->records= param->table->quick_rows[keynr]; ror_scan->records= param->table->quick_rows[keynr];
if (!(bitmap_buf= (uchar*)alloc_root(param->mem_root, if (!(bitmap_buf= (uchar*)alloc_root(param->mem_root,
param->fields_bitmap_size))) bytes_word_aligned(param->fields_bitmap_size))))
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
if (bitmap_init(&ror_scan->covered_fields, bitmap_buf, if (bitmap_init(&ror_scan->covered_fields, bitmap_buf,
...@@ -2441,7 +2442,8 @@ ROR_INTERSECT_INFO* ror_intersect_init(const PARAM *param) ...@@ -2441,7 +2442,8 @@ ROR_INTERSECT_INFO* ror_intersect_init(const PARAM *param)
sizeof(ROR_INTERSECT_INFO)))) sizeof(ROR_INTERSECT_INFO))))
return NULL; return NULL;
info->param= param; info->param= param;
if (!(buf= (uchar*)alloc_root(param->mem_root, param->fields_bitmap_size))) if (!(buf= (uchar*)alloc_root(param->mem_root,
bytes_word_aligned(param->fields_bitmap_size))))
return NULL; return NULL;
if (bitmap_init(&info->covered_fields, buf, param->fields_bitmap_size*8, if (bitmap_init(&info->covered_fields, buf, param->fields_bitmap_size*8,
FALSE)) FALSE))
...@@ -2998,7 +3000,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, ...@@ -2998,7 +3000,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
/*I=set of all covering indexes */ /*I=set of all covering indexes */
ror_scan_mark= tree->ror_scans; ror_scan_mark= tree->ror_scans;
uchar buf[MAX_KEY/8+1]; uint32 int_buf[MAX_KEY/32+1];
uchar *buf= (uchar*)&int_buf;
MY_BITMAP covered_fields; MY_BITMAP covered_fields;
if (bitmap_init(&covered_fields, buf, nbits, FALSE)) if (bitmap_init(&covered_fields, buf, nbits, FALSE))
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
template <uint default_width> class Bitmap template <uint default_width> class Bitmap
{ {
MY_BITMAP map; MY_BITMAP map;
uchar buffer[(default_width+7)/8]; uint32 buffer[(default_width+31)/32];
public: public:
Bitmap() { init(); } Bitmap() { init(); }
Bitmap(Bitmap& from) { *this=from; } Bitmap(Bitmap& from) { *this=from; }
...@@ -62,17 +62,18 @@ public: ...@@ -62,17 +62,18 @@ public:
char *print(char *buf) const char *print(char *buf) const
{ {
char *s=buf; int i; char *s=buf; int i;
uchar *uchar_buffer= (uchar*)&buffer;
for (i=sizeof(buffer)-1; i>=0 ; i--) for (i=sizeof(buffer)-1; i>=0 ; i--)
{ {
if ((*s=_dig_vec_upper[buffer[i] >> 4]) != '0') if ((*s=_dig_vec_upper[uchar_buffer[i] >> 4]) != '0')
break; break;
if ((*s=_dig_vec_upper[buffer[i] & 15]) != '0') if ((*s=_dig_vec_upper[uchar_buffer[i] & 15]) != '0')
break; break;
} }
for (s++, i-- ; i>=0 ; i--) for (s++, i-- ; i>=0 ; i--)
{ {
*s++=_dig_vec_upper[buffer[i] >> 4]; *s++=_dig_vec_upper[uchar_buffer[i] >> 4];
*s++=_dig_vec_upper[buffer[i] & 15]; *s++=_dig_vec_upper[uchar_buffer[i] & 15];
} }
*s=0; *s=0;
return buf; return buf;
......
...@@ -7946,7 +7946,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -7946,7 +7946,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status); statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
if (use_temp_pool) if (use_temp_pool)
temp_pool_slot = bitmap_set_next(&temp_pool); temp_pool_slot = bitmap_lock_set_next(&temp_pool);
if (temp_pool_slot != MY_BIT_NONE) // we got a slot if (temp_pool_slot != MY_BIT_NONE) // we got a slot
sprintf(filename, "%s_%lx_%i", tmp_file_prefix, sprintf(filename, "%s_%lx_%i", tmp_file_prefix,
...@@ -7998,12 +7998,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -7998,12 +7998,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
param->group_length : 0, param->group_length : 0,
NullS)) NullS))
{ {
bitmap_clear_bit(&temp_pool, temp_pool_slot); bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
DBUG_RETURN(NULL); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */
} }
if (!(param->copy_field=copy=new Copy_field[field_count])) if (!(param->copy_field=copy=new Copy_field[field_count]))
{ {
bitmap_clear_bit(&temp_pool, temp_pool_slot); bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
my_free((gptr) table,MYF(0)); /* purecov: inspected */ my_free((gptr) table,MYF(0)); /* purecov: inspected */
DBUG_RETURN(NULL); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */
} }
...@@ -8449,7 +8449,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -8449,7 +8449,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
err: err:
free_tmp_table(thd,table); /* purecov: inspected */ free_tmp_table(thd,table); /* purecov: inspected */
bitmap_clear_bit(&temp_pool, temp_pool_slot); bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
DBUG_RETURN(NULL); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */
} }
...@@ -8723,7 +8723,7 @@ free_tmp_table(THD *thd, TABLE *entry) ...@@ -8723,7 +8723,7 @@ free_tmp_table(THD *thd, TABLE *entry)
my_free((gptr) entry->record[0],MYF(0)); my_free((gptr) entry->record[0],MYF(0));
free_io_cache(entry); free_io_cache(entry);
bitmap_clear_bit(&temp_pool, entry->temp_pool_slot); bitmap_lock_clear_bit(&temp_pool, entry->temp_pool_slot);
my_free((gptr) entry,MYF(0)); my_free((gptr) entry,MYF(0));
thd->proc_info=save_proc_info; thd->proc_info=save_proc_info;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment