Commit c2b2cb8a authored by Sergei Golubchik's avatar Sergei Golubchik

TABLE::update_virtual_field to compute just one vcol

will be used later by storage engines (e.g. in MyISAM repair or in
InnoDB purge)
parent 2cdcf141
...@@ -985,6 +985,18 @@ bool Item_field::check_field_expression_processor(void *arg) ...@@ -985,6 +985,18 @@ bool Item_field::check_field_expression_processor(void *arg)
return 0; return 0;
} }
bool Item_field::update_vcol_processor(void *arg)
{
MY_BITMAP *map= (MY_BITMAP *) arg;
if (field->vcol_info &&
!bitmap_fast_test_and_set(map, field->field_index))
{
field->vcol_info->expr_item->walk(&Item::update_vcol_processor, 0, arg);
field->vcol_info->expr_item->save_in_field(field, 0);
}
return 0;
}
bool Item::check_cols(uint c) bool Item::check_cols(uint c)
{ {
......
...@@ -1635,6 +1635,7 @@ class Item: public Value_source, ...@@ -1635,6 +1635,7 @@ class Item: public Value_source,
timezone-dependent expressions in a (sub)partitioning function. timezone-dependent expressions in a (sub)partitioning function.
*/ */
virtual bool check_valid_arguments_processor(void *arg) { return 0; } virtual bool check_valid_arguments_processor(void *arg) { return 0; }
virtual bool update_vcol_processor(void *arg) { return 0; }
/*============== End of Item processor list ======================*/ /*============== End of Item processor list ======================*/
virtual Item *get_copy(THD *thd, MEM_ROOT *mem_root)=0; virtual Item *get_copy(THD *thd, MEM_ROOT *mem_root)=0;
...@@ -2580,6 +2581,7 @@ class Item_field :public Item_ident ...@@ -2580,6 +2581,7 @@ class Item_field :public Item_ident
bool enumerate_field_refs_processor(void *arg); bool enumerate_field_refs_processor(void *arg);
bool update_table_bitmaps_processor(void *arg); bool update_table_bitmaps_processor(void *arg);
bool switch_to_nullable_fields_processor(void *arg); bool switch_to_nullable_fields_processor(void *arg);
bool update_vcol_processor(void *arg);
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(field_name, arg, VCOL_FIELD_REF); return mark_unsupported_function(field_name, arg, VCOL_FIELD_REF);
...@@ -5091,6 +5093,7 @@ class Item_default_value : public Item_field ...@@ -5091,6 +5093,7 @@ class Item_default_value : public Item_field
} }
table_map used_tables() const { return (table_map)0L; } table_map used_tables() const { return (table_map)0L; }
Item_field *field_for_view_update() { return 0; } Item_field *field_for_view_update() { return 0; }
bool update_vcol_processor(void *arg) { return 0; }
bool walk(Item_processor processor, bool walk_subquery, void *args) bool walk(Item_processor processor, bool walk_subquery, void *args)
{ {
...@@ -5170,6 +5173,7 @@ class Item_insert_value : public Item_field ...@@ -5170,6 +5173,7 @@ class Item_insert_value : public Item_field
(this->*processor)(args); (this->*processor)(args);
} }
bool check_partition_func_processor(void *int_arg) {return TRUE;} bool check_partition_func_processor(void *int_arg) {return TRUE;}
bool update_vcol_processor(void *arg) { return 0; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function("values()", arg, VCOL_IMPOSSIBLE); return mark_unsupported_function("values()", arg, VCOL_IMPOSSIBLE);
......
...@@ -7333,6 +7333,18 @@ int TABLE::update_virtual_fields(enum_vcol_update_mode update_mode) ...@@ -7333,6 +7333,18 @@ int TABLE::update_virtual_fields(enum_vcol_update_mode update_mode)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int TABLE::update_virtual_field(Field *vf)
{
DBUG_ENTER("TABLE::update_virtual_field");
in_use->reset_arena_for_cached_items(expr_arena);
bitmap_clear_all(&tmp_set);
vf->vcol_info->expr_item->walk(&Item::update_vcol_processor, 0, &tmp_set);
vf->vcol_info->expr_item->save_in_field(vf, 0);
in_use->reset_arena_for_cached_items(0);
DBUG_RETURN(0);
}
/** /**
Update all DEFAULT and/or ON INSERT fields. Update all DEFAULT and/or ON INSERT fields.
......
...@@ -1423,6 +1423,7 @@ struct TABLE ...@@ -1423,6 +1423,7 @@ struct TABLE
uint actual_n_key_parts(KEY *keyinfo); uint actual_n_key_parts(KEY *keyinfo);
ulong actual_key_flags(KEY *keyinfo); ulong actual_key_flags(KEY *keyinfo);
int update_virtual_field(Field *vf);
int update_virtual_fields(enum_vcol_update_mode update_mode); int update_virtual_fields(enum_vcol_update_mode update_mode);
int update_default_fields(bool update, bool ignore_errors); int update_default_fields(bool update, bool ignore_errors);
void reset_default_fields(); void reset_default_fields();
......
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