Commit 9ca355a5 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-20250

The Insert_prelocking_strategy class added that prunes partition for the
INSERT INTO.
parent 7c5fdc9b
......@@ -1223,6 +1223,12 @@ class Field: public Value_source
return unireg_check == TIMESTAMP_DN_FIELD
|| unireg_check == TIMESTAMP_DNUN_FIELD;
}
bool has_default_update_unireg_check() const
{
return unireg_check == TIMESTAMP_UN_FIELD ||
unireg_check == TIMESTAMP_DNUN_FIELD;
}
/*
Mark the field as having a value supplied by the client, thus it should
......
......@@ -910,6 +910,20 @@ bool Item_field::register_field_in_bitmap(void *arg)
}
/*
@brief
Remove field from bitmap supplied as *arg
*/
bool Item_field::remove_field_from_bitmap(void *arg)
{
MY_BITMAP *bitmap= (MY_BITMAP *) arg;
DBUG_ASSERT(bitmap);
bitmap_clear_bit(bitmap, field->field_index);
return 0;
}
/*
Mark field in write_map
......
......@@ -2215,6 +2215,7 @@ class Item :public Value_source,
virtual bool register_field_in_read_map(void *arg) { return 0; }
virtual bool register_field_in_write_map(void *arg) { return 0; }
virtual bool register_field_in_bitmap(void *arg) { return 0; }
virtual bool remove_field_from_bitmap(void *arg) { return 0; }
virtual bool update_table_bitmaps_processor(void *arg) { return 0; }
virtual bool enumerate_field_refs_processor(void *arg) { return 0; }
......@@ -3783,6 +3784,7 @@ class Item_field :public Item_ident,
bool register_field_in_read_map(void *arg) override;
bool register_field_in_write_map(void *arg) override;
bool register_field_in_bitmap(void *arg) override;
bool remove_field_from_bitmap(void *arg) override;
bool check_partition_func_processor(void *) override {return false;}
bool post_fix_fields_part_expr_processor(void *bool_arg) override;
bool check_valid_arguments_processor(void *bool_arg) override;
......
......@@ -9005,7 +9005,7 @@ static bool vers_update_or_validate_fields(TABLE *table)
bool
fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
bool ignore_errors, bool update)
bool ignore_errors, bool update, MY_BITMAP *bitmap)
{
List_iterator_fast<Item> f(fields),v(values);
Item *value, *fld;
......@@ -9035,6 +9035,9 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
value=v++;
DBUG_ASSERT(value);
rfield= field->field;
/* If bitmap over wanted fields are set, skip non marked fields. */
if (bitmap && !bitmap_is_set(bitmap, rfield->field_index))
continue;
table= rfield->table;
if (table->next_number_field &&
rfield->field_index == table->next_number_field->field_index)
......@@ -9289,7 +9292,8 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table,
bool
fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
bool ignore_errors, bool use_value, bool check_for_computability)
bool ignore_errors, bool use_value, bool check_for_computability,
MY_BITMAP *bitmap)
{
List_iterator_fast<Item> v(values);
List<TABLE> tbl_list;
......@@ -9329,6 +9333,10 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
/* Ensure the end of the list of values is not reached */
DBUG_ASSERT(value);
/* If bitmap over wanted fields are set, skip non marked fields. */
if (bitmap && !bitmap_is_set(bitmap, field->field_index))
continue;
if (check_for_computability &&
value->check_is_evaluable_expression_or_error())
goto err;
......
......@@ -194,10 +194,11 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
bool allow_sum_func);
void unfix_fields(List<Item> &items);
bool fill_record(THD * thd, TABLE *table_arg, List<Item> &fields,
List<Item> &values, bool ignore_errors, bool update);
List<Item> &values, bool ignore_errors, bool update,
MY_BITMAP *bitmap= NULL);
bool fill_record(THD *thd, TABLE *table, Field **field, List<Item> &values,
bool ignore_errors, bool use_value,
bool check_for_evaluability);
bool check_for_evaluability, MY_BITMAP *bitmap= NULL);
Field *
find_field_in_tables(THD *thd, Item_ident *item,
......
This diff is collapsed.
......@@ -2597,6 +2597,43 @@ add_tables_and_routines_for_triggers(THD *thd,
}
/**
Check if any of the marked fields are used in the trigger.
@param used_fields Bitmap over fields to check
@param event_type Type of event triggers for which we are going to inspect
@param action_time Type of trigger action time we are going to inspect
*/
bool Table_triggers_list::is_fields_updated_in_trigger(MY_BITMAP *used_fields,
trg_event_type event_type, trg_action_time_type action_time)
{
DBUG_ASSERT(used_fields->n_bits == trigger_table->s->fields);
for (Trigger *trigger= get_trigger(event_type, action_time);
trigger; trigger= trigger->next)
{
for (SQL_I_List<Item_trigger_field>
*trg_fld_lst= trigger->body->m_trg_table_fields.first;
trg_fld_lst;
trg_fld_lst= trg_fld_lst->first->next_trig_field_list)
{
for (Item_trigger_field *trg_field= trg_fld_lst->first;
trg_field;
trg_field= trg_field->next_trg_field)
{
if (trg_field->field_idx != NO_CACHED_FIELD_INDEX &&
bitmap_is_set(used_fields, trg_field->field_idx) &&
trg_field->get_settable_routine_parameter())
return true;
}
}
}
return false;
}
/**
Mark fields of subject table which we read/set in its triggers
as such.
......
......@@ -307,6 +307,9 @@ class Table_triggers_list: public Sql_alloc
Query_tables_list *prelocking_ctx,
TABLE_LIST *table_list);
bool is_fields_updated_in_trigger(MY_BITMAP *used_fields,
trg_event_type event_type,
trg_action_time_type action_time);
Field **nullable_fields() { return record0_field; }
void reset_extra_null_bitmap()
{
......
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