diff options
author | Michael Widenius <monty@mariadb.org> | 2016-06-25 20:55:43 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-06-30 11:43:02 +0200 |
commit | 2fe8dd0f90e2bbe0180e30c36ebc9132fcdd4b06 (patch) | |
tree | 4d84b1ddb3e0af4660d52c0ac1792e85c652fc0d /sql/sql_base.cc | |
parent | db7edfed17efe6bc3684b0fbacc0b0249e4f0fa2 (diff) | |
download | mariadb-git-2fe8dd0f90e2bbe0180e30c36ebc9132fcdd4b06.tar.gz |
various cleanups
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index fbc26846fda..b8638ac5ee5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7728,7 +7728,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values, table_arg->auto_increment_field_not_null= FALSE; f.rewind(); } - else if (thd->lex->unit.insert_table_with_stored_vcol) + else vcol_table= thd->lex->unit.insert_table_with_stored_vcol; while ((fld= f++)) @@ -7796,6 +7796,7 @@ void switch_to_nullable_trigger_fields(List<Item> &items, TABLE *table) { Field** field= table->field_to_fill(); + /* True if we have NOT NULL fields and BEFORE triggers */ if (field != table->field) { List_iterator_fast<Item> it(items); @@ -7888,7 +7889,8 @@ static bool not_null_fields_have_null_values(TABLE *table) */ bool -fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields, +fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, + List<Item> &fields, List<Item> &values, bool ignore_errors, enum trg_event_type event) { @@ -7899,15 +7901,16 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields, event == TRG_EVENT_UPDATE); if (!result && triggers) - result= triggers->process_triggers(thd, event, TRG_ACTION_BEFORE, TRUE) || - not_null_fields_have_null_values(table); - - /* - Re-calculate virtual fields to cater for cases when base columns are - updated by the triggers. - */ - if (!result && triggers) { + if (triggers->process_triggers(thd, event, TRG_ACTION_BEFORE, + TRUE) || + not_null_fields_have_null_values(table)) + return TRUE; + + /* + Re-calculate virtual fields to cater for cases when base columns are + updated by the triggers. + */ List_iterator_fast<Item> f(fields); Item *fld; Item_field *item_field; @@ -7915,12 +7918,12 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields, { fld= (Item_field*)f++; item_field= fld->field_for_view_update(); - if (item_field && item_field->field && table && table->vfield) + if (item_field && table->vfield) { DBUG_ASSERT(table == item_field->field->table); result= update_virtual_fields(thd, table, table->triggers ? VCOL_UPDATE_ALL : - VCOL_UPDATE_FOR_WRITE); + VCOL_UPDATE_FOR_WRITE); } } } @@ -7930,6 +7933,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields, /** Fill the field buffer of a table with the values of an Item list + All fields are given a value @param thd thread handler @param table_arg the table that is being modified @@ -8005,7 +8009,8 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values, goto err; field->set_explicit_default(value); } - /* Update virtual fields*/ + /* There is no default fields to update, as all fields are updated */ + /* Update virtual fields */ thd->abort_on_warning= FALSE; if (table->vfield && update_virtual_fields(thd, table, @@ -8065,8 +8070,9 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr, DBUG_ASSERT(table == (*ptr)->table); if (table->vfield) result= update_virtual_fields(thd, table, - table->triggers ? VCOL_UPDATE_ALL : - VCOL_UPDATE_FOR_WRITE); + table->triggers ? + VCOL_UPDATE_ALL : + VCOL_UPDATE_FOR_WRITE); } return result; |