Commit e46c4221 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: TABLE::mark_columns_used_by_index()

mark_columns_used_by_index used to do
reset + mark_columns_used_by_index_no_reset + start keyread + set bitmaps

Now prepare_for_keyread does that, while mark_columns_used_by_index
does only reset + mark_columns_used_by_index_no_reset,
just as its name suggests.
parent 460ff398
......@@ -3224,7 +3224,7 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
int error;
MY_BITMAP *old_read_set;
old_read_set= table->mark_columns_used_by_index(table->s->next_number_index);
old_read_set= table->prepare_for_keyread(table->s->next_number_index);
if (ha_index_init(table->s->next_number_index, 1))
{
......@@ -3276,7 +3276,7 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment,
nr= ((ulonglong) table->next_number_field->
val_int_offset(table->s->rec_buff_length)+1);
ha_index_end();
table->restore_column_maps_after_mark_index(old_read_set);
table->restore_column_maps_after_keyread(old_read_set);
*first_value= nr;
return;
}
......
......@@ -465,8 +465,7 @@ void key_unpack(String *to, TABLE *table, KEY *key)
bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields)
{
bitmap_clear_all(&table->tmp_set);
table->mark_columns_used_by_index_no_reset(idx, &table->tmp_set);
table->mark_columns_used_by_index(idx, &table->tmp_set);
return bitmap_is_overlapping(&table->tmp_set, fields);
}
......
......@@ -1534,7 +1534,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler,
head->file= file;
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap, &column_bitmap);
head->mark_columns_used_by_index_in_bitmap(index, &column_bitmap);
head->prepare_for_keyread(index, &column_bitmap);
head->prepare_for_position();
head->file= org_file;
......
......@@ -6489,21 +6489,19 @@ void THD::binlog_prepare_row_images(TABLE *table)
*/
DBUG_ASSERT(table->read_set != &table->tmp_set);
bitmap_clear_all(&table->tmp_set);
switch(thd->variables.binlog_row_image)
{
case BINLOG_ROW_IMAGE_MINIMAL:
/* MINIMAL: Mark only PK */
table->mark_columns_used_by_index_no_reset(table->s->primary_key,
&table->tmp_set);
table->mark_columns_used_by_index(table->s->primary_key,
&table->tmp_set);
break;
case BINLOG_ROW_IMAGE_NOBLOB:
/**
NOBLOB: Remove unnecessary BLOB fields from read_set
(the ones that are not part of PK).
*/
bitmap_union(&table->tmp_set, table->read_set);
bitmap_copy(&table->tmp_set, table->read_set);
for (Field **ptr=table->field ; *ptr ; ptr++)
{
Field *field= (*ptr);
......
......@@ -191,7 +191,7 @@ static void prepare_record_for_error_message(int error, TABLE *table)
/* Create unique_map with all fields used by that index. */
my_bitmap_init(&unique_map, unique_map_buf, table->s->fields, FALSE);
table->mark_columns_used_by_index_no_reset(keynr, &unique_map);
table->mark_columns_used_by_index(keynr, &unique_map);
/* Subtract read_set and write_set. */
bitmap_subtract(&unique_map, table->read_set);
......@@ -539,7 +539,7 @@ int mysql_update(THD *thd,
MY_BITMAP *save_write_set= table->write_set;
if (query_plan.index < MAX_KEY && old_covering_keys.is_set(query_plan.index))
table->mark_columns_used_by_index(query_plan.index);
table->prepare_for_keyread(query_plan.index);
else
table->use_all_columns();
......
......@@ -6070,27 +6070,29 @@ void TABLE::prepare_for_position()
}
/*
Mark that only fields from one key is used
NOTE:
This changes the bitmap to use the tmp bitmap
After this, you can't access any other columns in the table until
bitmaps are reset, for example with TABLE::clear_column_bitmaps()
or TABLE::restore_column_maps_after_mark_index()
*/
MY_BITMAP *TABLE::mark_columns_used_by_index_in_bitmap(uint index,
MY_BITMAP *bitmap)
MY_BITMAP *TABLE::prepare_for_keyread(uint index, MY_BITMAP *map)
{
MY_BITMAP *backup= read_set;
DBUG_ENTER("TABLE::mark_columns_used_by_index_in_bitmap");
DBUG_ENTER("TABLE::prepare_for_keyread");
if (!no_keyread)
file->ha_start_keyread();
mark_columns_used_by_index(index, map);
column_bitmaps_set(map);
DBUG_RETURN(backup);
}
/*
Mark that only fields from one key is used. Useful before keyread.
*/
void TABLE::mark_columns_used_by_index(uint index, MY_BITMAP *bitmap)
{
DBUG_ENTER("TABLE::mark_columns_used_by_index");
bitmap_clear_all(bitmap);
mark_columns_used_by_index_no_reset(index, bitmap);
column_bitmaps_set(bitmap);
DBUG_RETURN(backup);
DBUG_VOID_RETURN;
}
/*
......@@ -6104,7 +6106,7 @@ MY_BITMAP *TABLE::mark_columns_used_by_index_in_bitmap(uint index,
when calling mark_columns_used_by_index
*/
void TABLE::restore_column_maps_after_mark_index(MY_BITMAP *backup)
void TABLE::restore_column_maps_after_keyread(MY_BITMAP *backup)
{
DBUG_ENTER("TABLE::restore_column_maps_after_mark_index");
file->ha_end_keyread();
......
......@@ -1306,11 +1306,12 @@ struct TABLE
void reset_item_list(List<Item> *item_list) const;
void clear_column_bitmaps(void);
void prepare_for_position(void);
MY_BITMAP *prepare_for_keyread(uint index, MY_BITMAP *map);
MY_BITMAP *prepare_for_keyread(uint index)
{ return prepare_for_keyread(index, &tmp_set); }
void mark_columns_used_by_index(uint index, MY_BITMAP *map);
void mark_columns_used_by_index_no_reset(uint index, MY_BITMAP *map);
MY_BITMAP *mark_columns_used_by_index_in_bitmap(uint index, MY_BITMAP *map);
MY_BITMAP *mark_columns_used_by_index(uint index)
{ return mark_columns_used_by_index_in_bitmap(index, &tmp_set); }
void restore_column_maps_after_mark_index(MY_BITMAP *backup);
void restore_column_maps_after_keyread(MY_BITMAP *backup);
void mark_auto_increment_column(void);
void mark_columns_needed_for_update(void);
void mark_columns_needed_for_delete(void);
......
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