diff --git a/mysql-test/suite/vcol/disabled.def b/mysql-test/suite/vcol/disabled.def index 86480ca3a4c22..e69de29bb2d1d 100644 --- a/mysql-test/suite/vcol/disabled.def +++ b/mysql-test/suite/vcol/disabled.def @@ -1 +0,0 @@ -vcol_keys_myisam : MDEV-11836 diff --git a/sql/handler.cc b/sql/handler.cc index 28fabeea69291..2aa905f70f605 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2580,7 +2580,7 @@ int handler::ha_rnd_next(uchar *buf) { update_rows_read(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); increment_statistics(&SSV::ha_read_rnd_next_count); } else if (result == HA_ERR_RECORD_DELETED) @@ -2608,7 +2608,7 @@ int handler::ha_rnd_pos(uchar *buf, uchar *pos) { update_rows_read(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; DBUG_RETURN(result); @@ -2631,7 +2631,7 @@ int handler::ha_index_read_map(uchar *buf, const uchar *key, { update_index_statistics(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; DBUG_RETURN(result); @@ -2660,7 +2660,7 @@ int handler::ha_index_read_idx_map(uchar *buf, uint index, const uchar *key, update_rows_read(); index_rows_read[index]++; if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; return result; @@ -2681,7 +2681,7 @@ int handler::ha_index_next(uchar * buf) { update_index_statistics(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; DBUG_RETURN(result); @@ -2702,7 +2702,7 @@ int handler::ha_index_prev(uchar * buf) { update_index_statistics(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; DBUG_RETURN(result); @@ -2722,7 +2722,7 @@ int handler::ha_index_first(uchar * buf) { update_index_statistics(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; return result; @@ -2742,7 +2742,7 @@ int handler::ha_index_last(uchar * buf) { update_index_statistics(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; return result; @@ -2762,7 +2762,7 @@ int handler::ha_index_next_same(uchar *buf, const uchar *key, uint keylen) { update_index_statistics(); if (table->vfield && buf == table->record[0]) - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); } table->status=result ? STATUS_NOT_FOUND: 0; return result; @@ -5911,7 +5911,7 @@ int handler::ha_reset() table->s->column_bitmap_size == (uchar*) table->def_write_set.bitmap); DBUG_ASSERT(bitmap_is_set_all(&table->s->all_set)); - DBUG_ASSERT(table->key_read == 0); + DBUG_ASSERT(table->file->key_read == 0); /* ensure that ha_index_end / ha_rnd_end has been called */ DBUG_ASSERT(inited == NONE); /* reset the bitmaps to point to defaults */ diff --git a/sql/handler.h b/sql/handler.h index 8b00ec8503bb6..017d045cdbc8c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2654,6 +2654,7 @@ class handler :public Sql_alloc uint errkey; /* Last dup key */ uint key_used_on_scan; uint active_index; + bool key_read; /** Length of ref (1-8 or the clustered key length) */ uint ref_length; @@ -2695,7 +2696,6 @@ class handler :public Sql_alloc public: void set_time_tracker(Exec_time_tracker *tracker_arg) { tracker=tracker_arg;} - Item *pushed_idx_cond; uint pushed_idx_cond_keyno; /* The index which the above condition is for */ @@ -2751,6 +2751,7 @@ class handler :public Sql_alloc in_range_check_pushed_down(FALSE), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), + key_read(false), ref_length(sizeof(my_off_t)), ft_handler(0), inited(NONE), pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0), @@ -2855,6 +2856,21 @@ class handler :public Sql_alloc int ha_delete_row(const uchar * buf); void ha_release_auto_increment(); + int ha_start_keyread() + { + if (key_read) + return 0; + key_read= 1; + return extra(HA_EXTRA_KEYREAD); + } + int ha_end_keyread() + { + if (!key_read) + return 0; + key_read= 0; + return extra(HA_EXTRA_NO_KEYREAD); + } + int check_collation_compatibility(); int ha_check_for_upgrade(HA_CHECK_OPT *check_opt); /** to be actually called to get 'check()' functionality*/ diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 8446da519266e..d41c4a452766e 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1236,7 +1236,7 @@ QUICK_SELECT_I::QUICK_SELECT_I() QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr, bool no_alloc, MEM_ROOT *parent_alloc, bool *create_error) - :doing_key_read(0),free_file(0),cur_range(NULL),last_range(0),dont_free(0) + :free_file(0),cur_range(NULL),last_range(0),dont_free(0) { my_bitmap_map *bitmap; DBUG_ENTER("QUICK_RANGE_SELECT::QUICK_RANGE_SELECT"); @@ -1318,8 +1318,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() if (file) { range_end(); - if (doing_key_read) - file->extra(HA_EXTRA_NO_KEYREAD); + file->ha_end_keyread(); if (free_file) { DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file, @@ -1475,7 +1474,6 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler, MEM_ROOT *local_alloc) { handler *save_file= file, *org_file; - my_bool org_key_read; THD *thd= head->in_use; MY_BITMAP * const save_vcol_set= head->vcol_set; MY_BITMAP * const save_read_set= head->read_set; @@ -1537,21 +1535,15 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler, key. The 'column_bitmap' is used in ::get_next() */ org_file= head->file; - org_key_read= head->key_read; head->file= file; - head->key_read= 0; head->mark_columns_used_by_index_no_reset(index, &column_bitmap); if (!head->no_keyread) - { - doing_key_read= 1; - head->set_keyread(true); - } + head->file->ha_start_keyread(); head->prepare_for_position(); head->file= org_file; - head->key_read= org_key_read; /* Restore head->read_set (and write_set) to what they had before the call */ head->column_bitmaps_set(save_read_set, save_write_set); @@ -10631,7 +10623,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, /* Call multi_range_read_info() to get the MRR flags and buffer size */ quick->mrr_flags= HA_MRR_NO_ASSOCIATION | - (table->key_read ? HA_MRR_INDEX_ONLY : 0); + (table->file->key_read ? HA_MRR_INDEX_ONLY : 0); if (thd->lex->sql_command != SQLCOM_SELECT) quick->mrr_flags |= HA_MRR_USE_DEFAULT_IMPL; @@ -10681,15 +10673,10 @@ int read_keys_and_merge_scans(THD *thd, Unique *unique= *unique_ptr; handler *file= head->file; bool with_cpk_filter= pk_quick_select != NULL; - bool enabled_keyread= 0; DBUG_ENTER("read_keys_and_merge"); /* We're going to just read rowids. */ - if (!head->key_read) - { - enabled_keyread= 1; - head->set_keyread(true); - } + head->file->ha_start_keyread(); head->prepare_for_position(); cur_quick_it.rewind(); @@ -10780,16 +10767,14 @@ int read_keys_and_merge_scans(THD *thd, /* index merge currently doesn't support "using index" at all */ - if (enabled_keyread) - head->set_keyread(false); + head->file->ha_end_keyread(); if (init_read_record(read_record, thd, head, (SQL_SELECT*) 0, &unique->sort, 1 , 1, TRUE)) result= 1; DBUG_RETURN(result); err: - if (enabled_keyread) - head->set_keyread(false); + head->file->ha_end_keyread(); DBUG_RETURN(1); } @@ -13340,7 +13325,7 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg, group_prefix_len(group_prefix_len_arg), group_key_parts(group_key_parts_arg), have_min(have_min_arg), have_max(have_max_arg), have_agg_distinct(have_agg_distinct_arg), - seen_first_key(FALSE), doing_key_read(FALSE), min_max_arg_part(min_max_arg_part_arg), + seen_first_key(FALSE), min_max_arg_part(min_max_arg_part_arg), key_infix(key_infix_arg), key_infix_len(key_infix_len_arg), min_functions_it(NULL), max_functions_it(NULL), is_index_scan(is_index_scan_arg) @@ -13480,8 +13465,7 @@ QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT() if (file->inited != handler::NONE) { DBUG_ASSERT(file == head->file); - if (doing_key_read) - head->set_keyread(false); + head->file->ha_end_keyread(); /* There may be a code path when the same table was first accessed by index, then the index is closed, and the table is scanned (order by + loose scan). @@ -13671,11 +13655,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset"); seen_first_key= FALSE; - if (!head->key_read) - { - doing_key_read= 1; - head->set_keyread(true); /* We need only the key attributes */ - } + head->file->ha_start_keyread(); /* We need only the key attributes */ + if ((result= file->ha_index_init(index,1))) { head->file->print_error(result, MYF(0)); diff --git a/sql/opt_range.h b/sql/opt_range.h index 9e4521a9437c1..c1f7079ce7f03 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -1037,7 +1037,6 @@ class QUICK_RANGE_SELECT : public QUICK_SELECT_I { protected: /* true if we enabled key only reads */ - bool doing_key_read; handler *file; /* Members to deal with case when this quick select is a ROR-merged scan */ diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index ad3f5aed112bd..9d229f6aeef9e 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -406,7 +406,7 @@ int opt_sum_query(THD *thd, if (!error && reckey_in_range(is_max, &ref, item_field->field, conds, range_fl, prefix_len)) error= HA_ERR_KEY_NOT_FOUND; - table->set_keyread(false); + table->file->ha_end_keyread(); table->file->ha_index_end(); if (error) { @@ -968,7 +968,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, converted (for example to upper case) */ if (field->part_of_key.is_set(idx)) - table->set_keyread(true); + table->file->ha_start_keyread(); DBUG_RETURN(TRUE); } } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index cdbef30952764..cdd70280eafaf 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -859,7 +859,7 @@ void close_thread_table(THD *thd, TABLE **table_ptr) DBUG_ENTER("close_thread_table"); DBUG_PRINT("tcache", ("table: '%s'.'%s' 0x%lx", table->s->db.str, table->s->table_name.str, (long) table)); - DBUG_ASSERT(table->key_read == 0); + DBUG_ASSERT(table->file->key_read == 0); DBUG_ASSERT(!table->file || table->file->inited == handler::NONE); /* @@ -7918,7 +7918,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, goto err; /* Update virtual fields */ if (table_arg->vfield && - table_arg->update_virtual_fields(VCOL_UPDATE_FOR_WRITE)) + table_arg->update_virtual_fields(table_arg->file, VCOL_UPDATE_FOR_WRITE)) goto err; thd->abort_on_warning= save_abort_on_warning; thd->no_errors= save_no_errors; @@ -8067,7 +8067,8 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, if (item_field) { DBUG_ASSERT(table == item_field->field->table); - result|= table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); + result|= table->update_virtual_fields(table->file, + VCOL_UPDATE_FOR_WRITE); } } } @@ -8163,7 +8164,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, /* Update virtual fields */ thd->abort_on_warning= FALSE; if (table->vfield && - table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE)) + table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_WRITE)) goto err; thd->abort_on_warning= abort_on_warning_saved; DBUG_RETURN(thd->is_error()); @@ -8217,7 +8218,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr, { DBUG_ASSERT(table == (*ptr)->table); if (table->vfield) - result= table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); + result= table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_WRITE); } return result; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 108fc51c569cf..eb5f0d7a477ae 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -562,7 +562,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, explain->tracker.on_record_read(); thd->inc_examined_row_count(1); if (table->vfield) - (void) table->update_virtual_fields(VCOL_UPDATE_FOR_DELETE); + (void) table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_DELETE); if (!select || select->skip_record(thd) > 0) { explain->tracker.on_record_after_where(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 8e8f6c7a26f99..27820c1654346 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1732,7 +1732,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) in handler methods for the just read row in record[1]. */ table->move_fields(table->field, table->record[1], table->record[0]); - table->update_virtual_fields(VCOL_UPDATE_FOR_REPLACE); + table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_REPLACE); table->move_fields(table->field, table->record[0], table->record[1]); } if (info->handle_duplicates == DUP_UPDATE) @@ -3268,7 +3268,8 @@ bool Delayed_insert::handle_inserts(void) TABLE object used had vcol_set empty. Better to calculate them here to make the caller faster. */ - tmp_error= table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); + tmp_error= table->update_virtual_fields(table->file, + VCOL_UPDATE_FOR_WRITE); } if (tmp_error || write_record(&thd, table, &info)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ac4b842e32860..ceb48616f9686 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11260,7 +11260,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) join_read_system :join_read_const; if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - table->set_keyread(true); + table->file->ha_start_keyread(); else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; @@ -11269,7 +11269,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) /* fall through */ if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - table->set_keyread(true); + table->file->ha_start_keyread(); else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; @@ -11284,7 +11284,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) tab->quick=0; if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - table->set_keyread(true); + table->file->ha_start_keyread(); else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; @@ -11347,7 +11347,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) if (tab->select && tab->select->quick && tab->select->quick->index != MAX_KEY && //not index_merge table->covering_keys.is_set(tab->select->quick->index)) - table->set_keyread(true); + table->file->ha_start_keyread(); else if (!table->covering_keys.is_clear_all() && !(tab->select && tab->select->quick)) { // Only read index tree @@ -11376,7 +11376,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) } } if (tab->select && tab->select->quick && - tab->select->quick->index != MAX_KEY && ! tab->table->key_read) + tab->select->quick->index != MAX_KEY && !tab->table->file->key_read) push_index_cond(tab, tab->select->quick->index); } break; @@ -11529,12 +11529,12 @@ void JOIN_TAB::cleanup() if (table && (table->s->tmp_table != INTERNAL_TMP_TABLE || table->is_created())) { - table->set_keyread(FALSE); + table->file->ha_end_keyread(); table->file->ha_index_or_rnd_end(); } if (table) { - table->set_keyread(false); + table->file->ha_end_keyread(); table->file->ha_index_or_rnd_end(); preread_init_done= FALSE; if (table->pos_in_table_list && @@ -18825,15 +18825,15 @@ join_read_const_table(THD *thd, JOIN_TAB *tab, POSITION *pos) } else { - if (!table->key_read && table->covering_keys.is_set(tab->ref.key) && - !table->no_keyread && + if (/*!table->file->key_read && */ + table->covering_keys.is_set(tab->ref.key) && !table->no_keyread && (int) table->reginfo.lock_type <= (int) TL_READ_HIGH_PRIORITY) { - table->set_keyread(true); + table->file->ha_start_keyread(); tab->index= tab->ref.key; } error=join_read_const(tab); - table->set_keyread(false); + table->file->ha_end_keyread(); if (error) { tab->info= ET_UNIQUE_ROW_NOT_FOUND; @@ -19348,9 +19348,8 @@ join_read_first(JOIN_TAB *tab) TABLE *table=tab->table; DBUG_ENTER("join_read_first"); - if (table->covering_keys.is_set(tab->index) && !table->no_keyread && - !table->key_read) - table->set_keyread(true); + if (table->covering_keys.is_set(tab->index) && !table->no_keyread) + table->file->ha_start_keyread(); tab->table->status=0; tab->read_record.read_record=join_read_next; tab->read_record.table=table; @@ -19388,9 +19387,8 @@ join_read_last(JOIN_TAB *tab) int error= 0; DBUG_ENTER("join_read_first"); - if (table->covering_keys.is_set(tab->index) && !table->no_keyread && - !table->key_read) - table->set_keyread(true); + if (table->covering_keys.is_set(tab->index) && !table->no_keyread) + table->file->ha_start_keyread(); tab->table->status=0; tab->read_record.read_record=join_read_prev; tab->read_record.table=table; @@ -21256,12 +21254,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, and best_key doesn't, then revert the decision. */ if (!table->covering_keys.is_set(best_key)) - table->set_keyread(false); + table->file->ha_end_keyread(); else - { - if (!table->key_read) - table->set_keyread(true); - } + table->file->ha_start_keyread(); if (!quick_created) { @@ -21291,7 +21286,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, tab->ref.key_parts= 0; if (select_limit < table->stat_records()) tab->limit= select_limit; - table->set_keyread(false); + table->file->ha_end_keyread(); } } else if (tab->type != JT_ALL || tab->select->quick) @@ -21465,7 +21460,7 @@ create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort) and in index_merge 'Only index' cannot be used */ if (((uint) tab->ref.key != select->quick->index)) - table->set_keyread(FALSE); + table->file->ha_end_keyread(); } else { @@ -21518,7 +21513,7 @@ create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort) select->cleanup(); } - table->set_keyread(FALSE); // Restore if we used indexes + table->file->ha_end_keyread(); if (tab->type == JT_FT) table->file->ft_end(); else @@ -24213,7 +24208,7 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, } /* Build "Extra" field and save it */ - key_read=table->key_read; + key_read=table->file->key_read; if ((tab_type == JT_NEXT || tab_type == JT_CONST) && table->covering_keys.is_set(index)) key_read=1; diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 6de8727876cc0..63e8b7bcec7b4 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2633,8 +2633,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index) DBUG_RETURN(rc); } - table->key_read= 1; - table->file->extra(HA_EXTRA_KEYREAD); + table->file->ha_start_keyread(); table->file->ha_index_init(index, TRUE); rc= table->file->ha_index_first(table->record[0]); @@ -2649,7 +2648,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index) index_prefix_calc.add(); rc= table->file->ha_index_next(table->record[0]); } - table->key_read= 0; + table->file->ha_end_keyread(); table->file->ha_index_end(); rc= (rc == HA_ERR_END_OF_FILE && !thd->killed) ? 0 : 1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3856cc4603115..eac610522844c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9839,7 +9839,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, if (to->default_field) to->update_default_fields(0, ignore); if (to->vfield) - to->update_virtual_fields(VCOL_UPDATE_FOR_WRITE); + to->update_virtual_fields(to->file, 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 c46b80f798b23..4aa68c51b3ebb 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -682,7 +682,7 @@ int mysql_update(THD *thd, if (error >= 0) goto err; } - table->set_keyread(false); + table->file->ha_end_keyread(); table->column_bitmaps_set(save_read_set, save_write_set); } @@ -1032,7 +1032,7 @@ int mysql_update(THD *thd, delete select; delete file_sort; free_underlaid_joins(thd, select_lex); - table->set_keyread(false); + table->file->ha_end_keyread(); thd->abort_on_warning= 0; DBUG_RETURN(1); @@ -2404,7 +2404,8 @@ int multi_update::do_updates() } while ((tbl= check_opt_it++)); if (table->vfield && - table->update_virtual_fields(VCOL_UPDATE_INDEXED_FOR_UPDATE)) + table->update_virtual_fields(table->file, + VCOL_UPDATE_INDEXED_FOR_UPDATE)) goto err2; table->status|= STATUS_UPDATED; @@ -2431,7 +2432,7 @@ int multi_update::do_updates() (error= table->update_default_fields(1, ignore))) goto err2; if (table->vfield && - table->update_virtual_fields(VCOL_UPDATE_FOR_WRITE)) + table->update_virtual_fields(table->file, 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 ca1fd3ac2629b..01481b3ec5634 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4447,7 +4447,7 @@ void TABLE::init(THD *thd, TABLE_LIST *tl) (*f_ptr)->cond_selectivity= 1.0; } - DBUG_ASSERT(key_read == 0); + DBUG_ASSERT(file->key_read == 0); /* mark the record[0] uninitialized */ TRASH_ALLOC(record[0], s->reclength); @@ -6096,7 +6096,7 @@ void TABLE::mark_columns_used_by_index(uint index) MY_BITMAP *bitmap= &tmp_set; DBUG_ENTER("TABLE::mark_columns_used_by_index"); - set_keyread(true); + file->ha_start_keyread(); bitmap_clear_all(bitmap); mark_columns_used_by_index_no_reset(index, bitmap); column_bitmaps_set(bitmap, bitmap); @@ -6117,7 +6117,7 @@ void TABLE::add_read_columns_used_by_index(uint index) MY_BITMAP *bitmap= &tmp_set; DBUG_ENTER("TABLE::add_read_columns_used_by_index"); - set_keyread(true); + file->ha_start_keyread(); bitmap_copy(bitmap, read_set); mark_columns_used_by_index_no_reset(index, bitmap); column_bitmaps_set(bitmap, write_set); @@ -6140,7 +6140,7 @@ void TABLE::restore_column_maps_after_mark_index() { DBUG_ENTER("TABLE::restore_column_maps_after_mark_index"); - set_keyread(false); + file->ha_end_keyread(); default_column_bitmaps(); file->column_bitmaps_signal(); DBUG_VOID_RETURN; @@ -7335,7 +7335,7 @@ class Turn_errors_to_warnings_handler : public Internal_error_handler >0 Error occurred when storing a virtual field value */ -int TABLE::update_virtual_fields(enum_vcol_update_mode update_mode) +int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) { DBUG_ENTER("TABLE::update_virtual_fields"); DBUG_PRINT("enter", ("update_mode: %d", update_mode)); @@ -7370,7 +7370,7 @@ int TABLE::update_virtual_fields(enum_vcol_update_mode update_mode) switch (update_mode) { case VCOL_UPDATE_FOR_READ: update= !vcol_info->stored_in_db - && !(key_read && vf->part_of_key.is_set(file->active_index)) + && !(h->key_read && vf->part_of_key.is_set(h->active_index)) && bitmap_is_set(vcol_set, vf->field_index); swap_values= 1; break; @@ -7400,7 +7400,7 @@ int TABLE::update_virtual_fields(enum_vcol_update_mode update_mode) /* 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) && - (key_read && vf->part_of_key.is_set(file->active_index))); + (h->key_read && vf->part_of_key.is_set(h->active_index))); swap_values= 1; break; } diff --git a/sql/table.h b/sql/table.h index 5b1c1d0d2ea79..9b171ef067445 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1245,11 +1245,6 @@ struct TABLE */ bool keep_row_order; - /** - If set, the optimizer has found that row retrieval should access index - tree only. - */ - bool key_read; bool no_keyread; /** If set, indicate that the table is not replicated by the server. @@ -1388,23 +1383,6 @@ struct TABLE tablenr= tablenr_arg; } - void set_keyread(bool flag) - { - DBUG_ASSERT(file); - if (flag && !key_read) - { - key_read= 1; - if (is_created()) - file->extra(HA_EXTRA_KEYREAD); - } - else if (!flag && key_read) - { - key_read= 0; - if (is_created()) - file->extra(HA_EXTRA_NO_KEYREAD); - } - } - /// Return true if table is instantiated, and false otherwise. bool is_created() const { return created; } @@ -1416,7 +1394,7 @@ struct TABLE { if (created) return; - if (key_read) + if (file->key_read) file->extra(HA_EXTRA_KEYREAD); created= true; } @@ -1438,7 +1416,7 @@ struct TABLE uint actual_n_key_parts(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(handler *h, 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/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8e41a631e5dff..d766dd6ada6e0 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1898,7 +1898,7 @@ innobase_row_to_mysql( } if (table->vfield) { my_bitmap_map* old_vcol_set = tmp_use_all_columns(table, table->vcol_set); - table->update_virtual_fields(VCOL_UPDATE_FOR_READ); + table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_READ); tmp_restore_column_map(table->vcol_set, old_vcol_set); } } diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 95908aea0998a..46a7734ef22b8 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -665,8 +665,8 @@ static int compute_vcols(MI_INFO *info, uchar *record, int keynum) table->move_fields(table->field, record, table->field[0]->record_ptr()); if (keynum == -1) // update all vcols { - int error= table->update_virtual_fields(VCOL_UPDATE_FOR_READ); - if (table->update_virtual_fields(VCOL_UPDATE_INDEXED)) + int error= table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_READ); + if (table->update_virtual_fields(table->file, VCOL_UPDATE_INDEXED)) error= 1; return error; }