diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-07-23 18:23:54 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-07-23 18:31:42 +0300 |
commit | c5ba13dda0464b1316bfb45efbcdcc924817f0de (patch) | |
tree | d7fc1c398d70a40cd11f890d1621a82e52412552 | |
parent | a7a0c533c20531aa658941a885a61b96f22110b2 (diff) | |
download | mariadb-git-c5ba13dda0464b1316bfb45efbcdcc924817f0de.tar.gz |
MDEV-15855 cleanup: Privatize purge_vcol_info_t
Declare all fields of purge_vcol_info_t private, and add
accessor functions.
-rw-r--r-- | storage/innobase/include/row0types.h | 36 | ||||
-rw-r--r-- | storage/innobase/row/row0purge.cc | 16 | ||||
-rw-r--r-- | storage/innobase/row/row0vers.cc | 11 |
3 files changed, 50 insertions, 13 deletions
diff --git a/storage/innobase/include/row0types.h b/storage/innobase/include/row0types.h index 005dc2ad95f..d2aef89f695 100644 --- a/storage/innobase/include/row0types.h +++ b/storage/innobase/include/row0types.h @@ -56,6 +56,7 @@ struct TABLE; /** Purge virtual column node information. */ struct purge_vcol_info_t { +private: /** Is there a possible need to evaluate virtual columns? */ bool requested; /** Do we have to evaluate virtual columns (using mariadb_table)? */ @@ -67,6 +68,7 @@ struct purge_vcol_info_t /** MariaDB table opened for virtual column computation. */ TABLE* mariadb_table; +public: /** Reset the state. */ void reset() { @@ -81,6 +83,29 @@ struct purge_vcol_info_t or doesn't try to calculate virtual column. */ bool validate() const { return !used || mariadb_table; } + /** @return the table handle for evaluating virtual columns */ + TABLE* table() const { return mariadb_table; } + + /** Set the table handle for evaluating virtual columns. + @param[in] table table handle */ + void set_table(TABLE* table) + { + ut_ad(!table || is_first_fetch()); + mariadb_table = table; + } + + /** Note that virtual column information may be needed. */ + void set_requested() + { + ut_ad(!used); + ut_ad(!first_use); + ut_ad(!mariadb_table); + requested = true; + } + + /** @return whether the virtual column information may be needed */ + bool is_requested() const { return requested; } + /** Note that the virtual column information is needed. */ void set_used() { @@ -97,11 +122,22 @@ struct purge_vcol_info_t } } + /** @return whether the virtual column information is needed */ + bool is_used() const + { + ut_ad(!first_use || used); + ut_ad(!used || requested); + ut_ad(used || !mariadb_table); + return used; + } + /** Check whether it fetches mariadb table for the first time. @return true if first time tries to open mariadb table. */ bool is_first_fetch() const { ut_ad(!first_use || used); + ut_ad(!used || requested); + ut_ad(used || !mariadb_table); return first_use; } }; diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index 59387f926ff..cc2dcc9b798 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -137,7 +137,7 @@ row_purge_remove_clust_if_poss_low( rec_offs_init(offsets_); ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S) - || node->vcol_info.used); + || node->vcol_info.is_used()); index = dict_table_get_first_index(node->table); @@ -250,7 +250,7 @@ static void row_purge_store_vsec_cur( return; } - node->vcol_info.requested = true; + node->vcol_info.set_requested(); btr_pcur_store_position(sec_pcur, sec_mtr); @@ -318,7 +318,7 @@ row_purge_poss_sec( ut_ad(!dict_index_is_clust(index)); - const bool store_cur = sec_mtr && !node->vcol_info.used + const bool store_cur = sec_mtr && !node->vcol_info.is_used() && dict_index_has_virtual(index); if (store_cur) { @@ -327,7 +327,7 @@ row_purge_poss_sec( /* The PRIMARY KEY value was not found in the clustered index. The secondary index record found. We can purge the secondary index record. */ - if (!node->vcol_info.requested) { + if (!node->vcol_info.is_requested()) { ut_ad(!node->found_clust); return true; } @@ -344,7 +344,9 @@ retry_purge_sec: &node->vcol_info); if (node->vcol_info.is_first_fetch()) { - if (node->vcol_info.mariadb_table) { + ut_ad(store_cur); + + if (node->vcol_info.table()) { node->vcol_info.set_used(); goto retry_purge_sec; } @@ -801,7 +803,7 @@ row_purge_upd_exist_or_extern_func( mem_heap_t* heap; ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S) - || node->vcol_info.used); + || node->vcol_info.is_used()); ut_ad(!node->table->skip_alter_undo); if (node->rec_type == TRX_UNDO_UPD_DEL_REC @@ -1139,7 +1141,7 @@ row_purge( bool purged = row_purge_record( node, undo_rec, thr, updated_extern); - if (!node->vcol_info.used) { + if (!node->vcol_info.is_used()) { rw_lock_s_unlock(dict_operation_lock); } diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc index 9ced22fd54b..f58f0a47bd5 100644 --- a/storage/innobase/row/row0vers.cc +++ b/storage/innobase/row/row0vers.cc @@ -457,7 +457,7 @@ row_vers_build_clust_v_col( if (vcol_info != NULL) { vcol_info->set_used(); - maria_table = vcol_info->mariadb_table; + maria_table = vcol_info->table(); } innobase_allocate_row_for_vcol(thd, index, @@ -466,9 +466,8 @@ row_vers_build_clust_v_col( &record, &vcol_storage); - if (vcol_info && !vcol_info->mariadb_table) { - vcol_info->mariadb_table = maria_table; - ut_ad(!maria_table || vcol_info->is_first_fetch()); + if (vcol_info && !vcol_info->table()) { + vcol_info->set_table(maria_table); goto func_exit; } @@ -834,7 +833,7 @@ row_vers_build_cur_vrow( rec, *clust_offsets, NULL, NULL, NULL, NULL, heap); - if (vcol_info && !vcol_info->used) { + if (vcol_info && !vcol_info->is_used()) { mtr->commit(); } @@ -955,7 +954,7 @@ row_vers_old_has_index_entry( if (trx_undo_roll_ptr_is_insert(t_roll_ptr) || dbug_v_purge) { - if (vcol_info && !vcol_info->used) { + if (vcol_info && !vcol_info->is_used()) { mtr->commit(); } |