Commit c5ba13dd authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-15855 cleanup: Privatize purge_vcol_info_t

Declare all fields of purge_vcol_info_t private, and add
accessor functions.
parent a7a0c533
...@@ -56,6 +56,7 @@ struct TABLE; ...@@ -56,6 +56,7 @@ struct TABLE;
/** Purge virtual column node information. */ /** Purge virtual column node information. */
struct purge_vcol_info_t struct purge_vcol_info_t
{ {
private:
/** Is there a possible need to evaluate virtual columns? */ /** Is there a possible need to evaluate virtual columns? */
bool requested; bool requested;
/** Do we have to evaluate virtual columns (using mariadb_table)? */ /** Do we have to evaluate virtual columns (using mariadb_table)? */
...@@ -67,6 +68,7 @@ struct purge_vcol_info_t ...@@ -67,6 +68,7 @@ struct purge_vcol_info_t
/** MariaDB table opened for virtual column computation. */ /** MariaDB table opened for virtual column computation. */
TABLE* mariadb_table; TABLE* mariadb_table;
public:
/** Reset the state. */ /** Reset the state. */
void reset() void reset()
{ {
...@@ -81,6 +83,29 @@ struct purge_vcol_info_t ...@@ -81,6 +83,29 @@ struct purge_vcol_info_t
or doesn't try to calculate virtual column. */ or doesn't try to calculate virtual column. */
bool validate() const { return !used || mariadb_table; } 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. */ /** Note that the virtual column information is needed. */
void set_used() void set_used()
{ {
...@@ -97,11 +122,22 @@ struct purge_vcol_info_t ...@@ -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. /** Check whether it fetches mariadb table for the first time.
@return true if first time tries to open mariadb table. */ @return true if first time tries to open mariadb table. */
bool is_first_fetch() const bool is_first_fetch() const
{ {
ut_ad(!first_use || used); ut_ad(!first_use || used);
ut_ad(!used || requested);
ut_ad(used || !mariadb_table);
return first_use; return first_use;
} }
}; };
......
...@@ -137,7 +137,7 @@ row_purge_remove_clust_if_poss_low( ...@@ -137,7 +137,7 @@ row_purge_remove_clust_if_poss_low(
rec_offs_init(offsets_); rec_offs_init(offsets_);
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S) 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); index = dict_table_get_first_index(node->table);
...@@ -250,7 +250,7 @@ static void row_purge_store_vsec_cur( ...@@ -250,7 +250,7 @@ static void row_purge_store_vsec_cur(
return; return;
} }
node->vcol_info.requested = true; node->vcol_info.set_requested();
btr_pcur_store_position(sec_pcur, sec_mtr); btr_pcur_store_position(sec_pcur, sec_mtr);
...@@ -318,7 +318,7 @@ row_purge_poss_sec( ...@@ -318,7 +318,7 @@ row_purge_poss_sec(
ut_ad(!dict_index_is_clust(index)); 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); && dict_index_has_virtual(index);
if (store_cur) { if (store_cur) {
...@@ -327,7 +327,7 @@ row_purge_poss_sec( ...@@ -327,7 +327,7 @@ row_purge_poss_sec(
/* The PRIMARY KEY value was not found in the clustered /* The PRIMARY KEY value was not found in the clustered
index. The secondary index record found. We can purge index. The secondary index record found. We can purge
the secondary index record. */ the secondary index record. */
if (!node->vcol_info.requested) { if (!node->vcol_info.is_requested()) {
ut_ad(!node->found_clust); ut_ad(!node->found_clust);
return true; return true;
} }
...@@ -344,7 +344,9 @@ row_purge_poss_sec( ...@@ -344,7 +344,9 @@ row_purge_poss_sec(
&node->vcol_info); &node->vcol_info);
if (node->vcol_info.is_first_fetch()) { 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(); node->vcol_info.set_used();
goto retry_purge_sec; goto retry_purge_sec;
} }
...@@ -801,7 +803,7 @@ row_purge_upd_exist_or_extern_func( ...@@ -801,7 +803,7 @@ row_purge_upd_exist_or_extern_func(
mem_heap_t* heap; mem_heap_t* heap;
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S) 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); ut_ad(!node->table->skip_alter_undo);
if (node->rec_type == TRX_UNDO_UPD_DEL_REC if (node->rec_type == TRX_UNDO_UPD_DEL_REC
...@@ -1139,7 +1141,7 @@ row_purge( ...@@ -1139,7 +1141,7 @@ row_purge(
bool purged = row_purge_record( bool purged = row_purge_record(
node, undo_rec, thr, updated_extern); node, undo_rec, thr, updated_extern);
if (!node->vcol_info.used) { if (!node->vcol_info.is_used()) {
rw_lock_s_unlock(dict_operation_lock); rw_lock_s_unlock(dict_operation_lock);
} }
......
...@@ -457,7 +457,7 @@ row_vers_build_clust_v_col( ...@@ -457,7 +457,7 @@ row_vers_build_clust_v_col(
if (vcol_info != NULL) { if (vcol_info != NULL) {
vcol_info->set_used(); vcol_info->set_used();
maria_table = vcol_info->mariadb_table; maria_table = vcol_info->table();
} }
innobase_allocate_row_for_vcol(thd, index, innobase_allocate_row_for_vcol(thd, index,
...@@ -466,9 +466,8 @@ row_vers_build_clust_v_col( ...@@ -466,9 +466,8 @@ row_vers_build_clust_v_col(
&record, &record,
&vcol_storage); &vcol_storage);
if (vcol_info && !vcol_info->mariadb_table) { if (vcol_info && !vcol_info->table()) {
vcol_info->mariadb_table = maria_table; vcol_info->set_table(maria_table);
ut_ad(!maria_table || vcol_info->is_first_fetch());
goto func_exit; goto func_exit;
} }
...@@ -834,7 +833,7 @@ row_vers_build_cur_vrow( ...@@ -834,7 +833,7 @@ row_vers_build_cur_vrow(
rec, *clust_offsets, rec, *clust_offsets,
NULL, NULL, NULL, NULL, heap); NULL, NULL, NULL, NULL, heap);
if (vcol_info && !vcol_info->used) { if (vcol_info && !vcol_info->is_used()) {
mtr->commit(); mtr->commit();
} }
...@@ -955,7 +954,7 @@ row_vers_old_has_index_entry( ...@@ -955,7 +954,7 @@ row_vers_old_has_index_entry(
if (trx_undo_roll_ptr_is_insert(t_roll_ptr) if (trx_undo_roll_ptr_is_insert(t_roll_ptr)
|| dbug_v_purge) { || dbug_v_purge) {
if (vcol_info && !vcol_info->used) { if (vcol_info && !vcol_info->is_used()) {
mtr->commit(); mtr->commit();
} }
......
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