mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
cleanup: remove TABLE::vcol_set
use a read_set instead. a bit in the read_set means "the field value is needed" (read or generated, whatever it takes).
This commit is contained in:
parent
ac9cc63892
commit
45dee3fc83
22 changed files with 95 additions and 219 deletions
|
@ -63,7 +63,7 @@ const char field_separator=',';
|
|||
((ulong) ((1LL << MY_MIN(arg, 4) * 8) - 1))
|
||||
|
||||
#define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
|
||||
#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED DBUG_ASSERT(is_stat_field || !table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || (table->vcol_set && bitmap_is_set(table->vcol_set, field_index))))
|
||||
#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED DBUG_ASSERT(is_stat_field || !table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || bitmap_is_set(table->read_set, field_index)))
|
||||
|
||||
#define FLAGSTR(S,F) ((S) & (F) ? #F " " : "")
|
||||
|
||||
|
|
|
@ -710,7 +710,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
|||
uchar *ref_pos, *next_pos, ref_buff[MAX_REFLENGTH];
|
||||
TABLE *sort_form;
|
||||
handler *file;
|
||||
MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set;
|
||||
MY_BITMAP *save_read_set, *save_write_set;
|
||||
Item *sort_cond;
|
||||
ha_rows retval;
|
||||
DBUG_ENTER("find_all_keys");
|
||||
|
@ -745,13 +745,11 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
|||
/* Remember original bitmaps */
|
||||
save_read_set= sort_form->read_set;
|
||||
save_write_set= sort_form->write_set;
|
||||
save_vcol_set= sort_form->vcol_set;
|
||||
|
||||
/* Set up temporary column read map for columns used by sort */
|
||||
DBUG_ASSERT(save_read_set != &sort_form->tmp_set);
|
||||
bitmap_clear_all(&sort_form->tmp_set);
|
||||
sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set,
|
||||
&sort_form->tmp_set);
|
||||
sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set);
|
||||
register_used_fields(param);
|
||||
if (quick_select)
|
||||
select->quick->add_used_key_part_to_set();
|
||||
|
@ -809,16 +807,12 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
|||
*/
|
||||
MY_BITMAP *tmp_read_set= sort_form->read_set;
|
||||
MY_BITMAP *tmp_write_set= sort_form->write_set;
|
||||
MY_BITMAP *tmp_vcol_set= sort_form->vcol_set;
|
||||
|
||||
if (select->cond->with_subquery())
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set,
|
||||
save_vcol_set);
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set);
|
||||
write_record= (select->skip_record(thd) > 0);
|
||||
if (select->cond->with_subquery())
|
||||
sort_form->column_bitmaps_set(tmp_read_set,
|
||||
tmp_write_set,
|
||||
tmp_vcol_set);
|
||||
sort_form->column_bitmaps_set(tmp_read_set, tmp_write_set);
|
||||
}
|
||||
else
|
||||
write_record= true;
|
||||
|
@ -864,7 +858,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
|||
}
|
||||
|
||||
/* Signal we should use orignal column read and write maps */
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set);
|
||||
|
||||
if (unlikely(thd->is_error()))
|
||||
DBUG_RETURN(HA_POS_ERROR);
|
||||
|
@ -885,7 +879,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
|
|||
DBUG_RETURN(retval);
|
||||
|
||||
err:
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
|
||||
sort_form->column_bitmaps_set(save_read_set, save_write_set);
|
||||
DBUG_RETURN(HA_POS_ERROR);
|
||||
} /* find_all_keys */
|
||||
|
||||
|
|
|
@ -10647,8 +10647,6 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
|
|||
{
|
||||
/* Only need to read the partitioning fields. */
|
||||
bitmap_union(table->read_set, &m_part_info->full_part_field_set);
|
||||
if (table->vcol_set)
|
||||
bitmap_union(table->vcol_set, &m_part_info->full_part_field_set);
|
||||
}
|
||||
|
||||
if ((result= m_file[read_part_id]->ha_rnd_init(1)))
|
||||
|
|
|
@ -934,11 +934,12 @@ bool Item_field::register_field_in_read_map(void *arg)
|
|||
return res;
|
||||
|
||||
if (field->vcol_info &&
|
||||
!bitmap_fast_test_and_set(field->table->vcol_set, field->field_index))
|
||||
!bitmap_fast_test_and_set(field->table->read_set, field->field_index))
|
||||
{
|
||||
res= field->vcol_info->expr->walk(&Item::register_field_in_read_map,1,arg);
|
||||
}
|
||||
bitmap_set_bit(field->table->read_set, field->field_index);
|
||||
else
|
||||
bitmap_set_bit(field->table->read_set, field->field_index);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
43
sql/item.h
43
sql/item.h
|
@ -3193,13 +3193,7 @@ public:
|
|||
TABLE *tab= field->table;
|
||||
tab->covering_keys.intersect(field->part_of_key);
|
||||
if (tab->read_set)
|
||||
bitmap_fast_test_and_set(tab->read_set, field->field_index);
|
||||
/*
|
||||
Do not mark a self-referecing virtual column.
|
||||
Such virtual columns are reported as invalid.
|
||||
*/
|
||||
if (field->vcol_info && tab->vcol_set)
|
||||
tab->mark_virtual_col(field);
|
||||
tab->mark_column_with_deps(field);
|
||||
}
|
||||
}
|
||||
void update_used_tables()
|
||||
|
@ -6839,4 +6833,39 @@ inline void Virtual_column_info::print(String* str)
|
|||
expr->print_for_table_def(str);
|
||||
}
|
||||
|
||||
inline bool TABLE::mark_column_with_deps(Field *field)
|
||||
{
|
||||
bool res;
|
||||
if (!(res= bitmap_fast_test_and_set(read_set, field->field_index)))
|
||||
{
|
||||
if (field->vcol_info)
|
||||
mark_virtual_column_deps(field);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
inline bool TABLE::mark_virtual_column_with_deps(Field *field)
|
||||
{
|
||||
bool res;
|
||||
DBUG_ASSERT(field->vcol_info);
|
||||
if (!(res= bitmap_fast_test_and_set(read_set, field->field_index)))
|
||||
mark_virtual_column_deps(field);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline void TABLE::mark_virtual_column_deps(Field *field)
|
||||
{
|
||||
DBUG_ASSERT(field->vcol_info);
|
||||
DBUG_ASSERT(field->vcol_info->expr);
|
||||
field->vcol_info->expr->walk(&Item::register_field_in_read_map, 1, 0);
|
||||
}
|
||||
|
||||
inline void TABLE::use_all_stored_columns()
|
||||
{
|
||||
bitmap_set_all(read_set);
|
||||
if (Field **vf= vfield)
|
||||
for (; *vf; vf++)
|
||||
bitmap_clear_bit(read_set, (*vf)->field_index);
|
||||
}
|
||||
|
||||
#endif /* SQL_ITEM_INCLUDED */
|
||||
|
|
|
@ -1479,7 +1479,6 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler,
|
|||
{
|
||||
handler *save_file= file, *org_file;
|
||||
THD *thd= head->in_use;
|
||||
MY_BITMAP * const save_vcol_set= head->vcol_set;
|
||||
MY_BITMAP * const save_read_set= head->read_set;
|
||||
MY_BITMAP * const save_write_set= head->write_set;
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::init_ror_merged_scan");
|
||||
|
@ -1537,14 +1536,14 @@ end:
|
|||
org_file= head->file;
|
||||
head->file= file;
|
||||
|
||||
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap, &column_bitmap);
|
||||
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap);
|
||||
head->prepare_for_keyread(index, &column_bitmap);
|
||||
head->prepare_for_position();
|
||||
|
||||
head->file= org_file;
|
||||
|
||||
/* Restore head->read_set (and write_set) to what they had before the call */
|
||||
head->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
|
||||
head->column_bitmaps_set(save_read_set, save_write_set);
|
||||
|
||||
if (reset())
|
||||
{
|
||||
|
@ -1559,7 +1558,7 @@ end:
|
|||
DBUG_RETURN(0);
|
||||
|
||||
failure:
|
||||
head->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set);
|
||||
head->column_bitmaps_set(save_read_set, save_write_set);
|
||||
delete file;
|
||||
file= save_file;
|
||||
DBUG_RETURN(1);
|
||||
|
@ -11350,7 +11349,6 @@ int QUICK_RANGE_SELECT::reset()
|
|||
HANDLER_BUFFER empty_buf;
|
||||
MY_BITMAP * const save_read_set= head->read_set;
|
||||
MY_BITMAP * const save_write_set= head->write_set;
|
||||
MY_BITMAP * const save_vcol_set= head->vcol_set;
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::reset");
|
||||
last_range= NULL;
|
||||
cur_range= (QUICK_RANGE**) ranges.buffer;
|
||||
|
@ -11364,8 +11362,7 @@ int QUICK_RANGE_SELECT::reset()
|
|||
}
|
||||
|
||||
if (in_ror_merged_scan)
|
||||
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap,
|
||||
&column_bitmap);
|
||||
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap);
|
||||
|
||||
if (file->inited == handler::NONE)
|
||||
{
|
||||
|
@ -11411,8 +11408,7 @@ int QUICK_RANGE_SELECT::reset()
|
|||
err:
|
||||
/* Restore bitmaps set on entry */
|
||||
if (in_ror_merged_scan)
|
||||
head->column_bitmaps_set_no_signal(save_read_set, save_write_set,
|
||||
save_vcol_set);
|
||||
head->column_bitmaps_set_no_signal(save_read_set, save_write_set);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -11443,16 +11439,13 @@ int QUICK_RANGE_SELECT::get_next()
|
|||
|
||||
MY_BITMAP * const save_read_set= head->read_set;
|
||||
MY_BITMAP * const save_write_set= head->write_set;
|
||||
MY_BITMAP * const save_vcol_set= head->vcol_set;
|
||||
/*
|
||||
We don't need to signal the bitmap change as the bitmap is always the
|
||||
same for this head->file
|
||||
*/
|
||||
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap,
|
||||
&column_bitmap);
|
||||
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap);
|
||||
result= file->multi_range_read_next(&dummy);
|
||||
head->column_bitmaps_set_no_signal(save_read_set, save_write_set,
|
||||
save_vcol_set);
|
||||
head->column_bitmaps_set_no_signal(save_read_set, save_write_set);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -497,7 +497,9 @@ int prepare_record(TABLE *const table, const uint skip, const bool check)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
/**
|
||||
Fills @c table->record[0] with computed values of extra persistent column which are present on slave but not on master.
|
||||
Fills @c table->record[0] with computed values of extra persistent column
|
||||
which are present on slave but not on master.
|
||||
|
||||
@param table Table whose record[0] buffer is prepared.
|
||||
@param master_cols No of columns on master
|
||||
@returns 0 on success
|
||||
|
@ -514,10 +516,8 @@ int fill_extra_persistent_columns(TABLE *table, int master_cols)
|
|||
vfield= *vfield_ptr;
|
||||
if (vfield->field_index >= master_cols && vfield->stored_in_db())
|
||||
{
|
||||
/*Set bitmap for writing*/
|
||||
bitmap_set_bit(table->vcol_set, vfield->field_index);
|
||||
bitmap_set_bit(table->write_set, vfield->field_index);
|
||||
error= vfield->vcol_info->expr->save_in_field(vfield,0);
|
||||
bitmap_clear_bit(table->vcol_set, vfield->field_index);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
|
|
|
@ -5412,43 +5412,27 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
|
|||
DBUG_ENTER("update_field_dependencies");
|
||||
if (should_mark_column(thd->column_usage))
|
||||
{
|
||||
MY_BITMAP *bitmap;
|
||||
|
||||
/*
|
||||
We always want to register the used keys, as the column bitmap may have
|
||||
been set for all fields (for example for view).
|
||||
*/
|
||||
|
||||
table->covering_keys.intersect(field->part_of_key);
|
||||
|
||||
if (field->vcol_info)
|
||||
table->mark_virtual_col(field);
|
||||
|
||||
if (thd->column_usage == MARK_COLUMNS_READ)
|
||||
bitmap= table->read_set;
|
||||
else
|
||||
bitmap= table->write_set;
|
||||
|
||||
/*
|
||||
The test-and-set mechanism in the bitmap is not reliable during
|
||||
multi-UPDATE statements under MARK_COLUMNS_READ mode
|
||||
(thd->column_usage == MARK_COLUMNS_READ), as this bitmap contains
|
||||
only those columns that are used in the SET clause. I.e they are being
|
||||
set here. See multi_update::prepare()
|
||||
*/
|
||||
if (bitmap_fast_test_and_set(bitmap, field->field_index))
|
||||
{
|
||||
if (thd->column_usage == MARK_COLUMNS_WRITE)
|
||||
if (table->mark_column_with_deps(field))
|
||||
DBUG_VOID_RETURN; // Field was already marked
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bitmap_fast_test_and_set(table->write_set, field->field_index))
|
||||
{
|
||||
DBUG_PRINT("warning", ("Found duplicated field"));
|
||||
thd->dup_field= field;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_PRINT("note", ("Field found before"));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
table->used_fields++;
|
||||
}
|
||||
if (table->get_fields_in_item_tree)
|
||||
|
@ -7865,18 +7849,9 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
|||
|
||||
if ((field= field_iterator.field()))
|
||||
{
|
||||
/* Mark fields as used to allow storage engine to optimze access */
|
||||
bitmap_set_bit(field->table->read_set, field->field_index);
|
||||
/*
|
||||
Mark virtual fields for write and others that the virtual fields
|
||||
depend on for read.
|
||||
*/
|
||||
if (field->vcol_info)
|
||||
field->table->mark_virtual_col(field);
|
||||
field->table->mark_column_with_deps(field);
|
||||
if (table)
|
||||
{
|
||||
table->covering_keys.intersect(field->part_of_key);
|
||||
}
|
||||
if (tables->is_natural_join)
|
||||
{
|
||||
TABLE *field_table;
|
||||
|
|
|
@ -433,8 +433,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
|
|||
|
||||
/* Always read all columns */
|
||||
table->read_set= &table->s->all_set;
|
||||
if (table->vcol_set)
|
||||
table->vcol_set= &table->s->all_set;
|
||||
|
||||
/* Restore the state. */
|
||||
thd->set_open_tables(backup_open_tables);
|
||||
|
|
|
@ -2605,10 +2605,6 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
|
|||
share->default_fields)
|
||||
{
|
||||
bool error_reported= FALSE;
|
||||
if (unlikely(!(copy->def_vcol_set=
|
||||
(MY_BITMAP*) alloc_root(client_thd->mem_root,
|
||||
sizeof(MY_BITMAP)))))
|
||||
goto error;
|
||||
if (unlikely(parse_vcol_defs(client_thd, client_thd->mem_root, copy,
|
||||
&error_reported)))
|
||||
goto error;
|
||||
|
@ -2627,15 +2623,6 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
|
|||
copy->def_write_set.bitmap= ((my_bitmap_map*)
|
||||
(bitmap + share->column_bitmap_size));
|
||||
bitmaps_used= 2;
|
||||
if (share->virtual_fields)
|
||||
{
|
||||
my_bitmap_init(copy->def_vcol_set,
|
||||
(my_bitmap_map*) (bitmap +
|
||||
bitmaps_used*share->column_bitmap_size),
|
||||
share->fields, FALSE);
|
||||
bitmaps_used++;
|
||||
copy->vcol_set= copy->def_vcol_set;
|
||||
}
|
||||
if (share->default_fields || share->default_expressions)
|
||||
{
|
||||
my_bitmap_init(©->has_value_set,
|
||||
|
|
|
@ -4360,7 +4360,7 @@ void SELECT_LEX::update_used_tables()
|
|||
tab->covering_keys= tab->s->keys_for_keyread;
|
||||
tab->covering_keys.intersect(tab->keys_in_use_for_query);
|
||||
/*
|
||||
View/derived was merged. Need to recalculate read_set/vcol_set
|
||||
View/derived was merged. Need to recalculate read_set
|
||||
bitmaps here. For example:
|
||||
CREATE VIEW v1 AS SELECT f1,f2,f3 FROM t1;
|
||||
SELECT f1 FROM v1;
|
||||
|
@ -4369,8 +4369,6 @@ void SELECT_LEX::update_used_tables()
|
|||
be in the read_set.
|
||||
*/
|
||||
bitmap_clear_all(tab->read_set);
|
||||
if (tab->vcol_set)
|
||||
bitmap_clear_all(tab->vcol_set);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -525,15 +525,10 @@ static bool create_full_part_field_array(THD *thd, TABLE *table,
|
|||
full_part_field_array may be NULL if storage engine supports native
|
||||
partitioning.
|
||||
*/
|
||||
table->vcol_set= table->read_set= &part_info->full_part_field_set;
|
||||
table->read_set= &part_info->full_part_field_set;
|
||||
if ((ptr= part_info->full_part_field_array))
|
||||
for (; *ptr; ptr++)
|
||||
{
|
||||
if ((*ptr)->vcol_info)
|
||||
table->mark_virtual_col(*ptr);
|
||||
else
|
||||
bitmap_fast_test_and_set(table->read_set, (*ptr)->field_index);
|
||||
}
|
||||
table->mark_column_with_deps(*ptr);
|
||||
table->default_column_bitmaps();
|
||||
|
||||
end:
|
||||
|
|
|
@ -16907,7 +16907,7 @@ setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps, uint field_count)
|
|||
{
|
||||
uint bitmap_size= bitmap_buffer_size(field_count);
|
||||
|
||||
DBUG_ASSERT(table->s->virtual_fields == 0 && table->def_vcol_set == 0);
|
||||
DBUG_ASSERT(table->s->virtual_fields == 0);
|
||||
|
||||
my_bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count,
|
||||
FALSE);
|
||||
|
|
|
@ -10659,7 +10659,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
|
|||
ha_checksum crc= 0;
|
||||
uchar null_mask=256 - (1 << t->s->last_null_bit_pos);
|
||||
|
||||
t->use_all_columns();
|
||||
t->use_all_stored_columns();
|
||||
|
||||
if (t->file->ha_rnd_init(1))
|
||||
protocol->store_null();
|
||||
|
|
|
@ -2312,12 +2312,10 @@ void Table_triggers_list::mark_fields_used(trg_event_type event)
|
|||
if (trg_field->field_idx != (uint)-1)
|
||||
{
|
||||
DBUG_PRINT("info", ("marking field: %d", trg_field->field_idx));
|
||||
bitmap_set_bit(trigger_table->read_set, trg_field->field_idx);
|
||||
if (trg_field->get_settable_routine_parameter())
|
||||
bitmap_set_bit(trigger_table->write_set, trg_field->field_idx);
|
||||
if (trigger_table->field[trg_field->field_idx]->vcol_info)
|
||||
trigger_table->mark_virtual_col(trigger_table->
|
||||
field[trg_field->field_idx]);
|
||||
trigger_table->mark_column_with_deps(
|
||||
trigger_table->field[trg_field->field_idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2536,17 +2536,10 @@ int multi_update::do_updates()
|
|||
not its dependencies
|
||||
*/
|
||||
while(TABLE *tbl= check_opt_it++)
|
||||
{
|
||||
if (tbl->vcol_set)
|
||||
{
|
||||
bitmap_clear_all(tbl->vcol_set);
|
||||
for (Field **vf= tbl->vfield; *vf; vf++)
|
||||
{
|
||||
if (Field **vf= tbl->vfield)
|
||||
for (; *vf; vf++)
|
||||
if (bitmap_is_set(tbl->read_set, (*vf)->field_index))
|
||||
tbl->mark_virtual_col(*vf);
|
||||
}
|
||||
}
|
||||
}
|
||||
(*vf)->vcol_info->expr->walk(&Item::register_field_in_read_map, 1, 0);
|
||||
|
||||
for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local)
|
||||
{
|
||||
|
|
79
sql/table.cc
79
sql/table.cc
|
@ -3465,17 +3465,6 @@ partititon_err:
|
|||
(my_bitmap_map*) bitmaps, share->fields, FALSE);
|
||||
bitmaps+= bitmap_size;
|
||||
|
||||
/* Don't allocate vcol_bitmap if we don't need it */
|
||||
if (share->virtual_fields)
|
||||
{
|
||||
if (!(outparam->def_vcol_set= (MY_BITMAP*)
|
||||
alloc_root(&outparam->mem_root, sizeof(*outparam->def_vcol_set))))
|
||||
goto err;
|
||||
my_bitmap_init(outparam->def_vcol_set,
|
||||
(my_bitmap_map*) bitmaps, share->fields, FALSE);
|
||||
bitmaps+= bitmap_size;
|
||||
}
|
||||
|
||||
my_bitmap_init(&outparam->has_value_set,
|
||||
(my_bitmap_map*) bitmaps, share->fields, FALSE);
|
||||
bitmaps+= bitmap_size;
|
||||
|
@ -6285,13 +6274,12 @@ void TABLE::clear_column_bitmaps()
|
|||
Reset column read/write usage. It's identical to:
|
||||
bitmap_clear_all(&table->def_read_set);
|
||||
bitmap_clear_all(&table->def_write_set);
|
||||
if (s->virtual_fields) bitmap_clear_all(table->def_vcol_set);
|
||||
The code assumes that the bitmaps are allocated after each other, as
|
||||
guaranteed by open_table_from_share()
|
||||
*/
|
||||
bzero((char*) def_read_set.bitmap,
|
||||
s->column_bitmap_size * (s->virtual_fields ? 3 : 2));
|
||||
column_bitmaps_set(&def_read_set, &def_write_set, def_vcol_set);
|
||||
column_bitmaps_set(&def_read_set, &def_write_set);
|
||||
rpl_write_set= 0; // Safety
|
||||
}
|
||||
|
||||
|
@ -6439,11 +6427,7 @@ void TABLE::mark_columns_needed_for_delete()
|
|||
for (reg_field= field ; *reg_field ; reg_field++)
|
||||
{
|
||||
if ((*reg_field)->flags & PART_KEY_FLAG)
|
||||
{
|
||||
bitmap_set_bit(read_set, (*reg_field)->field_index);
|
||||
if ((*reg_field)->vcol_info)
|
||||
mark_virtual_col(*reg_field);
|
||||
}
|
||||
mark_column_with_deps(*reg_field);
|
||||
}
|
||||
need_signal= true;
|
||||
}
|
||||
|
@ -6522,13 +6506,7 @@ void TABLE::mark_columns_needed_for_update()
|
|||
if (any_written && !all_read)
|
||||
{
|
||||
for (KEY_PART_INFO *kp= k->key_part; kp < kpend; kp++)
|
||||
{
|
||||
int idx= kp->fieldnr - 1;
|
||||
if (bitmap_fast_test_and_set(read_set, idx))
|
||||
continue;
|
||||
if (field[idx]->vcol_info)
|
||||
mark_virtual_col(field[idx]);
|
||||
}
|
||||
mark_column_with_deps(field[kp->fieldnr - 1]);
|
||||
}
|
||||
}
|
||||
need_signal= true;
|
||||
|
@ -6725,49 +6703,12 @@ void TABLE::mark_columns_per_binlog_row_image()
|
|||
DBUG_ASSERT(FALSE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
We have to ensure that all virtual columns that are part of read set
|
||||
are calculated.
|
||||
*/
|
||||
if (vcol_set)
|
||||
bitmap_union(vcol_set, read_set);
|
||||
file->column_bitmaps_signal();
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief Mark a column as virtual used by the query
|
||||
|
||||
@param field the field for the column to be marked
|
||||
|
||||
@details
|
||||
The function marks the column for 'field' as virtual (computed)
|
||||
in the bitmap vcol_set.
|
||||
If the column is marked for the first time the expression to compute
|
||||
the column is traversed and all columns that are occurred there are
|
||||
marked in the read_set of the table.
|
||||
|
||||
@retval
|
||||
TRUE if column is marked for the first time
|
||||
@retval
|
||||
FALSE otherwise
|
||||
*/
|
||||
|
||||
bool TABLE::mark_virtual_col(Field *field)
|
||||
{
|
||||
bool res;
|
||||
DBUG_ASSERT(field->vcol_info);
|
||||
if (!(res= bitmap_fast_test_and_set(vcol_set, field->field_index)))
|
||||
{
|
||||
Item *vcol_item= field->vcol_info->expr;
|
||||
DBUG_ASSERT(vcol_item);
|
||||
vcol_item->walk(&Item::register_field_in_read_map, 1, 0);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief Mark virtual columns for update/insert commands
|
||||
|
@ -6809,12 +6750,12 @@ bool TABLE::mark_virtual_columns_for_write(bool insert_fl
|
|||
{
|
||||
tmp_vfield= *vfield_ptr;
|
||||
if (bitmap_is_set(write_set, tmp_vfield->field_index))
|
||||
bitmap_updated|= mark_virtual_col(tmp_vfield);
|
||||
bitmap_updated|= mark_virtual_column_with_deps(tmp_vfield);
|
||||
else if (tmp_vfield->vcol_info->stored_in_db ||
|
||||
(tmp_vfield->flags & (PART_KEY_FLAG | FIELD_IN_PART_FUNC_FLAG)))
|
||||
{
|
||||
bitmap_set_bit(write_set, tmp_vfield->field_index);
|
||||
mark_virtual_col(tmp_vfield);
|
||||
mark_virtual_column_with_deps(tmp_vfield);
|
||||
bitmap_updated= true;
|
||||
}
|
||||
}
|
||||
|
@ -6904,8 +6845,6 @@ void TABLE::mark_columns_used_by_check_constraints(void)
|
|||
void TABLE::mark_check_constraint_columns_for_read(void)
|
||||
{
|
||||
bitmap_union(read_set, s->check_set);
|
||||
if (vcol_set)
|
||||
bitmap_union(vcol_set, s->check_set);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7667,16 +7606,16 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
|
|||
switch (update_mode) {
|
||||
case VCOL_UPDATE_FOR_READ:
|
||||
update= (!vcol_info->stored_in_db &&
|
||||
bitmap_is_set(vcol_set, vf->field_index));
|
||||
bitmap_is_set(read_set, vf->field_index));
|
||||
swap_values= 1;
|
||||
break;
|
||||
case VCOL_UPDATE_FOR_DELETE:
|
||||
case VCOL_UPDATE_FOR_WRITE:
|
||||
update= bitmap_is_set(vcol_set, vf->field_index);
|
||||
update= bitmap_is_set(read_set, vf->field_index);
|
||||
break;
|
||||
case VCOL_UPDATE_FOR_REPLACE:
|
||||
update= ((!vcol_info->stored_in_db && (vf->flags & PART_KEY_FLAG) &&
|
||||
bitmap_is_set(vcol_set, vf->field_index)) ||
|
||||
bitmap_is_set(read_set, vf->field_index)) ||
|
||||
update_all_columns);
|
||||
if (update && (vf->flags & BLOB_FLAG))
|
||||
{
|
||||
|
@ -7695,7 +7634,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
|
|||
case VCOL_UPDATE_INDEXED_FOR_UPDATE:
|
||||
/* Read indexed fields that was not updated in VCOL_UPDATE_FOR_READ */
|
||||
update= (!vcol_info->stored_in_db && (vf->flags & PART_KEY_FLAG) &&
|
||||
!bitmap_is_set(vcol_set, vf->field_index));
|
||||
!bitmap_is_set(read_set, vf->field_index));
|
||||
swap_values= 1;
|
||||
break;
|
||||
}
|
||||
|
|
26
sql/table.h
26
sql/table.h
|
@ -1150,8 +1150,6 @@ public:
|
|||
MY_BITMAP cond_set; /* used to mark fields from sargable conditions*/
|
||||
/* Active column sets */
|
||||
MY_BITMAP *read_set, *write_set, *rpl_write_set;
|
||||
/* Set if using virtual fields */
|
||||
MY_BITMAP *vcol_set, *def_vcol_set;
|
||||
/* On INSERT: fields that the user specified a value for */
|
||||
MY_BITMAP has_value_set;
|
||||
|
||||
|
@ -1372,7 +1370,9 @@ public:
|
|||
void mark_columns_needed_for_delete(void);
|
||||
void mark_columns_needed_for_insert(void);
|
||||
void mark_columns_per_binlog_row_image(void);
|
||||
bool mark_virtual_col(Field *field);
|
||||
inline bool mark_column_with_deps(Field *field);
|
||||
inline bool mark_virtual_column_with_deps(Field *field);
|
||||
inline void mark_virtual_column_deps(Field *field);
|
||||
bool mark_virtual_columns_for_write(bool insert_fl);
|
||||
bool check_virtual_columns_marked_for_read();
|
||||
bool check_virtual_columns_marked_for_write();
|
||||
|
@ -1394,39 +1394,21 @@ public:
|
|||
if (file)
|
||||
file->column_bitmaps_signal();
|
||||
}
|
||||
inline void column_bitmaps_set(MY_BITMAP *read_set_arg,
|
||||
MY_BITMAP *write_set_arg,
|
||||
MY_BITMAP *vcol_set_arg)
|
||||
{
|
||||
read_set= read_set_arg;
|
||||
write_set= write_set_arg;
|
||||
vcol_set= vcol_set_arg;
|
||||
if (file)
|
||||
file->column_bitmaps_signal();
|
||||
}
|
||||
inline void column_bitmaps_set_no_signal(MY_BITMAP *read_set_arg,
|
||||
MY_BITMAP *write_set_arg)
|
||||
{
|
||||
read_set= read_set_arg;
|
||||
write_set= write_set_arg;
|
||||
}
|
||||
inline void column_bitmaps_set_no_signal(MY_BITMAP *read_set_arg,
|
||||
MY_BITMAP *write_set_arg,
|
||||
MY_BITMAP *vcol_set_arg)
|
||||
{
|
||||
read_set= read_set_arg;
|
||||
write_set= write_set_arg;
|
||||
vcol_set= vcol_set_arg;
|
||||
}
|
||||
inline void use_all_columns()
|
||||
{
|
||||
column_bitmaps_set(&s->all_set, &s->all_set);
|
||||
}
|
||||
inline void use_all_stored_columns();
|
||||
inline void default_column_bitmaps()
|
||||
{
|
||||
read_set= &def_read_set;
|
||||
write_set= &def_write_set;
|
||||
vcol_set= def_vcol_set; /* Note that this may be 0 */
|
||||
rpl_write_set= 0;
|
||||
}
|
||||
/** Should this instance of the table be reopened? */
|
||||
|
|
|
@ -2085,9 +2085,8 @@ int ha_connect::MakeRecord(char *buf)
|
|||
DBUG_ENTER("ha_connect::MakeRecord");
|
||||
|
||||
if (trace(2))
|
||||
htrc("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n",
|
||||
htrc("Maps: read=%08X write=%08X defr=%08X defw=%08X\n",
|
||||
*table->read_set->bitmap, *table->write_set->bitmap,
|
||||
(table->vcol_set) ? *table->vcol_set->bitmap : 0,
|
||||
*table->def_read_set.bitmap, *table->def_write_set.bitmap);
|
||||
|
||||
// Avoid asserts in field::store() for columns that are not updated
|
||||
|
|
|
@ -5269,7 +5269,7 @@ ha_innobase::keys_to_use_for_scanning()
|
|||
/****************************************************************//**
|
||||
Ensures that if there's a concurrent inplace ADD INDEX, being-indexed virtual
|
||||
columns are computed. They are not marked as indexed in the old table, so the
|
||||
server won't add them to the vcol_set automatically */
|
||||
server won't add them to the read_set automatically */
|
||||
void
|
||||
ha_innobase::column_bitmaps_signal()
|
||||
/*================================*/
|
||||
|
@ -5289,7 +5289,7 @@ ha_innobase::column_bitmaps_signal()
|
|||
if (col->ord_part ||
|
||||
(dict_index_is_online_ddl(clust_index) &&
|
||||
row_log_col_is_indexed(clust_index, num_v))) {
|
||||
table->mark_virtual_col(table->vfield[j]);
|
||||
table->mark_virtual_column_with_deps(table->vfield[j]);
|
||||
}
|
||||
num_v++;
|
||||
}
|
||||
|
@ -10765,9 +10765,8 @@ prepare_vcol_for_base_setup(
|
|||
ut_ad(col->base_col == NULL);
|
||||
|
||||
MY_BITMAP *old_read_set = field->table->read_set;
|
||||
MY_BITMAP *old_vcol_set = field->table->vcol_set;
|
||||
|
||||
field->table->read_set = field->table->vcol_set = &field->table->tmp_set;
|
||||
field->table->read_set = &field->table->tmp_set;
|
||||
|
||||
bitmap_clear_all(&field->table->tmp_set);
|
||||
field->vcol_info->expr->walk(
|
||||
|
@ -10779,7 +10778,6 @@ prepare_vcol_for_base_setup(
|
|||
* col->base_col)));
|
||||
}
|
||||
field->table->read_set= old_read_set;
|
||||
field->table->vcol_set= old_vcol_set;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2299,9 +2299,9 @@ innobase_row_to_mysql(
|
|||
}
|
||||
}
|
||||
if (table->vfield) {
|
||||
my_bitmap_map* old_vcol_set = tmp_use_all_columns(table, table->vcol_set);
|
||||
my_bitmap_map* old_read_set = tmp_use_all_columns(table, table->read_set);
|
||||
table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_READ);
|
||||
tmp_restore_column_map(table->vcol_set, old_vcol_set);
|
||||
tmp_restore_column_map(table->read_set, old_read_set);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -946,7 +946,6 @@ void ha_myisam::setup_vcols_for_repair(HA_CHECK *param)
|
|||
}
|
||||
param->fix_record= compute_vcols;
|
||||
table->use_all_columns();
|
||||
table->vcol_set= &table->s->all_set;
|
||||
}
|
||||
|
||||
void ha_myisam::restore_vcos_after_repair()
|
||||
|
|
Loading…
Reference in a new issue