diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-11-07 21:47:48 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-12-12 20:27:33 +0100 |
commit | 9a3ec79b53ea1916211b4134375ebde5fb7c914c (patch) | |
tree | 0730e7a7669bb5635ae77041d028655038184795 | |
parent | 8b6c0542db908bba548bdb217d78bae25d4522ca (diff) | |
download | mariadb-git-9a3ec79b53ea1916211b4134375ebde5fb7c914c.tar.gz |
cleanup: TABLE::update_virtual_fields
Make update_virtual_fields() a method of TABLE, to be consistent
with TABLE::update_default_fields().
-rw-r--r-- | sql/filesort.cc | 4 | ||||
-rw-r--r-- | sql/sql_base.cc | 8 | ||||
-rw-r--r-- | sql/sql_base.h | 2 | ||||
-rw-r--r-- | sql/sql_delete.cc | 2 | ||||
-rw-r--r-- | sql/sql_handler.cc | 2 | ||||
-rw-r--r-- | sql/sql_join_cache.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/sql_update.cc | 6 | ||||
-rw-r--r-- | sql/table.cc | 38 | ||||
-rw-r--r-- | sql/table.h | 1 | ||||
-rw-r--r-- | storage/oqgraph/oqgraph_thunk.cc | 12 |
12 files changed, 43 insertions, 48 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index ae51fb94e64..e2f18f99135 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -785,7 +785,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, if ((error= select->quick->get_next())) break; if (!error && sort_form->vfield) - update_virtual_fields(thd, sort_form); + sort_form->update_virtual_fields(VCOL_UPDATE_FOR_READ); file->position(sort_form->record[0]); DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE);); } @@ -794,7 +794,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, { error= file->ha_rnd_next(sort_form->record[0]); if (!error && sort_form->vfield) - update_virtual_fields(thd, sort_form); + sort_form->update_virtual_fields(VCOL_UPDATE_FOR_READ); if (!flag) { my_store_ptr(ref_pos,ref_length,record); // Position to row diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 86f2b24829f..9bd0c062cdc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7837,7 +7837,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values, /* Update virtual fields */ thd->abort_on_warning= FALSE; if (vcol_table && vcol_table->vfield && - update_virtual_fields(thd, vcol_table, VCOL_UPDATE_FOR_WRITE)) + vcol_table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE)) goto err; thd->abort_on_warning= save_abort_on_warning; thd->no_errors= save_no_errors; @@ -7988,7 +7988,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, if (item_field && table->vfield) { DBUG_ASSERT(table == item_field->field->table); - result= update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE); + result= table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); } } } @@ -8081,7 +8081,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values, /* Update virtual fields */ thd->abort_on_warning= FALSE; if (table->vfield && - update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE)) + table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE)) goto err; thd->abort_on_warning= abort_on_warning_saved; DBUG_RETURN(thd->is_error()); @@ -8135,7 +8135,7 @@ 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, VCOL_UPDATE_FOR_WRITE); + result= table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); } return result; diff --git a/sql/sql_base.h b/sql/sql_base.h index bdfbe400e54..2c0e6850d04 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -288,8 +288,6 @@ TABLE *find_table_for_mdl_upgrade(THD *thd, const char *db, const char *table_name, bool no_error); -int update_virtual_fields(THD *thd, TABLE *table, - enum enum_vcol_update_mode vcol_update_mode= VCOL_UPDATE_FOR_READ); int dynamic_column_error_message(enum_dyncol_func_result rc); /* open_and_lock_tables with optional derived handling */ diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index a4e43f87bd0..d0da7f9dc2d 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -561,7 +561,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { explain->tracker.on_record_read(); if (table->vfield) - update_virtual_fields(thd, table, VCOL_UPDATE_FOR_READ_WRITE); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ_WRITE); thd->inc_examined_row_count(1); // thd->is_error() is tested to disallow delete row on error if (!select || select->skip_record(thd) > 0) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 405e7ce8c38..bab33919e03 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -931,7 +931,7 @@ retry: } /* Generate values for virtual fields */ if (table->vfield) - update_virtual_fields(thd, table); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ); if (cond && !cond->val_int()) { if (thd->is_error()) diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index d5883b1304e..71721336722 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -3383,7 +3383,7 @@ int JOIN_TAB_SCAN::next() { join_tab->tracker->r_rows++; if (table->vfield) - update_virtual_fields(thd, table); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ); } while (!err && select && (skip_rc= select->skip_record(thd)) <= 0) @@ -3399,7 +3399,7 @@ int JOIN_TAB_SCAN::next() { join_tab->tracker->r_rows++; if (table->vfield) - update_virtual_fields(thd, table); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ); } } @@ -3924,7 +3924,7 @@ int JOIN_TAB_SCAN_MRR::next() (uchar *) (*ptr) <= cache->end_pos); */ if (join_tab->table->vfield) - update_virtual_fields(join->thd, join_tab->table); + join_tab->table->update_virtual_fields(VCOL_UPDATE_FOR_READ); } return rc; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e76b6a5a48a..ed121191209 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18444,7 +18444,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, join_tab->tracker->r_rows++; if (join_tab->table->vfield) - update_virtual_fields(join->thd, join_tab->table); + join_tab->table->update_virtual_fields(VCOL_UPDATE_FOR_READ); if (select_cond) { @@ -18897,7 +18897,7 @@ join_read_system(JOIN_TAB *tab) return -1; } if (table->vfield) - update_virtual_fields(tab->join->thd, table); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ); store_record(table,record[1]); } else if (!table->status) // Only happens with left join @@ -18944,7 +18944,7 @@ join_read_const(JOIN_TAB *tab) return -1; } if (table->vfield) - update_virtual_fields(tab->join->thd, table); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ); store_record(table,record[1]); } else if (!(table->status & ~STATUS_NULL_ROW)) // Only happens with left join diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 632290703be..710d7decc25 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9789,7 +9789,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, break; } if (from->vfield) - update_virtual_fields(thd, from); + from->update_virtual_fields(VCOL_UPDATE_FOR_READ); if (++thd->progress.counter >= time_to_report_progress) { time_to_report_progress+= MY_HOW_OFTEN_TO_WRITE/10; @@ -9819,7 +9819,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, if (to->default_field) to->update_default_fields(0, ignore); if (to->vfield) - update_virtual_fields(thd, to, VCOL_UPDATE_FOR_WRITE); + to->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); /* This will set thd->is_error() if fatal failure */ if (to->verify_constraints(ignore) == VIEW_CHECK_SKIP) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 3a4bffeb454..1ae90a31ebf 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -619,7 +619,7 @@ int mysql_update(THD *thd, { explain->buf_tracker.on_record_read(); if (table->vfield) - update_virtual_fields(thd, table, VCOL_UPDATE_FOR_READ_WRITE); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ_WRITE); thd->inc_examined_row_count(1); if (!select || (error= select->skip_record(thd)) > 0) { @@ -736,7 +736,7 @@ int mysql_update(THD *thd, { explain->tracker.on_record_read(); if (table->vfield) - update_virtual_fields(thd, table, VCOL_UPDATE_FOR_READ_WRITE); + table->update_virtual_fields(VCOL_UPDATE_FOR_READ_WRITE); thd->inc_examined_row_count(1); if (!select || select->skip_record(thd) > 0) { @@ -2407,7 +2407,7 @@ int multi_update::do_updates() (error= table->update_default_fields(1, ignore))) goto err2; if (table->vfield && - update_virtual_fields(thd, table, VCOL_UPDATE_FOR_WRITE)) + table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE)) goto err2; if ((error= cur_table->view_check_option(thd, ignore)) != VIEW_CHECK_OK) diff --git a/sql/table.cc b/sql/table.cc index 8bc2ef35bcf..092ec79f21b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -7262,9 +7262,7 @@ bool is_simple_order(ORDER *order) /* @brief Compute values for virtual columns used in query - @param thd Thread handle - @param table The TABLE object - @param vcol_update_mode Specifies what virtual column are computed + @param update_mode Specifies what virtual column are computed @details The function computes the values of the virtual columns of the table and @@ -7276,52 +7274,50 @@ bool is_simple_order(ORDER *order) >0 Error occurred when storing a virtual field value */ -int update_virtual_fields(THD *thd, TABLE *table, - enum enum_vcol_update_mode vcol_update_mode) +int TABLE::update_virtual_fields(enum_vcol_update_mode update_mode) { - DBUG_ENTER("update_virtual_fields"); - Field **vfield_ptr, *vfield; - DBUG_ASSERT(table); - DBUG_ASSERT(table->vfield); + DBUG_ENTER("TABLE::update_virtual_fields"); + Field **vfield_ptr, *vf; + DBUG_ASSERT(vfield); - thd->reset_arena_for_cached_items(table->expr_arena); + in_use->reset_arena_for_cached_items(expr_arena); /* Iterate over virtual fields in the table */ - for (vfield_ptr= table->vfield; *vfield_ptr; vfield_ptr++) + for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++) { - vfield= (*vfield_ptr); - Virtual_column_info *vcol_info= vfield->vcol_info; + vf= (*vfield_ptr); + Virtual_column_info *vcol_info= vf->vcol_info; DBUG_ASSERT(vcol_info); DBUG_ASSERT(vcol_info->expr_item); bool update; - switch (vcol_update_mode) { + switch (update_mode) { case VCOL_UPDATE_FOR_READ_WRITE: - if (table->triggers) + if (triggers) { update= true; break; } case VCOL_UPDATE_FOR_READ: update= !vcol_info->stored_in_db - && bitmap_is_set(table->vcol_set, vfield->field_index); + && bitmap_is_set(vcol_set, vf->field_index); break; case VCOL_UPDATE_FOR_WRITE: - update= table->triggers || bitmap_is_set(table->vcol_set, vfield->field_index); + update= triggers || bitmap_is_set(vcol_set, vf->field_index); break; } if (update) { /* Compute the actual value of the virtual fields */ - vcol_info->expr_item->save_in_field(vfield, 0); - DBUG_PRINT("info", ("field '%s' - updated", vfield->field_name)); + vcol_info->expr_item->save_in_field(vf, 0); + DBUG_PRINT("info", ("field '%s' - updated", vf->field_name)); } else { - DBUG_PRINT("info", ("field '%s' - skipped", vfield->field_name)); + DBUG_PRINT("info", ("field '%s' - skipped", vf->field_name)); } } - thd->reset_arena_for_cached_items(0); + in_use->reset_arena_for_cached_items(0); DBUG_RETURN(0); } diff --git a/sql/table.h b/sql/table.h index e05fa903773..14b6a26c650 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1421,6 +1421,7 @@ public: uint actual_n_key_parts(KEY *keyinfo); ulong actual_key_flags(KEY *keyinfo); + int update_virtual_fields(enum_vcol_update_mode update_mode); int update_default_fields(bool update, bool ignore_errors); void reset_default_fields(); inline ha_rows stat_records() { return used_stat_records; } diff --git a/storage/oqgraph/oqgraph_thunk.cc b/storage/oqgraph/oqgraph_thunk.cc index 0ffd5cca414..128e6191d98 100644 --- a/storage/oqgraph/oqgraph_thunk.cc +++ b/storage/oqgraph/oqgraph_thunk.cc @@ -194,7 +194,7 @@ int oqgraph3::cursor::restore_position() } if (table.vfield) - update_virtual_fields(table.in_use, &table); + table.update_virtual_fields(VCOL_UPDATE_FOR_READ); table.file->position(table.record[0]); @@ -207,7 +207,7 @@ int oqgraph3::cursor::restore_position() } if (table.vfield) - update_virtual_fields(table.in_use, &table); + table.update_virtual_fields(VCOL_UPDATE_FOR_READ); if ((_origid && vertex_id(_graph->_source->val_int()) != *_origid) || (_destid && vertex_id(_graph->_target->val_int()) != *_destid)) @@ -232,7 +232,7 @@ int oqgraph3::cursor::restore_position() } if (table.vfield) - update_virtual_fields(table.in_use, &table); + table.update_virtual_fields(VCOL_UPDATE_FOR_READ); } _graph->_cursor= this; @@ -311,7 +311,7 @@ int oqgraph3::cursor::seek_next() } if (table.vfield) - update_virtual_fields(table.in_use, &table); + table.update_virtual_fields(VCOL_UPDATE_FOR_READ); _graph->_stale= true; if ((_origid && vertex_id(_graph->_source->val_int()) != *_origid) || @@ -346,7 +346,7 @@ int oqgraph3::cursor::seek_prev() } if (table.vfield) - update_virtual_fields(table.in_use, &table); + table.update_virtual_fields(VCOL_UPDATE_FOR_READ); _graph->_stale= true; if ((_origid && vertex_id(_graph->_source->val_int()) != *_origid) || @@ -508,7 +508,7 @@ int oqgraph3::cursor::seek_to( } if (table.vfield) - update_virtual_fields(table.in_use, &table); + table.update_virtual_fields(VCOL_UPDATE_FOR_READ); if ((_origid && vertex_id(_graph->_source->val_int()) != *_origid) || (_destid && vertex_id(_graph->_target->val_int()) != *_destid)) |