Skip to content

Commit c5ba13d

Browse files
committed
MDEV-15855 cleanup: Privatize purge_vcol_info_t
Declare all fields of purge_vcol_info_t private, and add accessor functions.
1 parent a7a0c53 commit c5ba13d

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

storage/innobase/include/row0types.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct TABLE;
5656
/** Purge virtual column node information. */
5757
struct purge_vcol_info_t
5858
{
59+
private:
5960
/** Is there a possible need to evaluate virtual columns? */
6061
bool requested;
6162
/** Do we have to evaluate virtual columns (using mariadb_table)? */
@@ -67,6 +68,7 @@ struct purge_vcol_info_t
6768
/** MariaDB table opened for virtual column computation. */
6869
TABLE* mariadb_table;
6970

71+
public:
7072
/** Reset the state. */
7173
void reset()
7274
{
@@ -81,6 +83,29 @@ struct purge_vcol_info_t
8183
or doesn't try to calculate virtual column. */
8284
bool validate() const { return !used || mariadb_table; }
8385

86+
/** @return the table handle for evaluating virtual columns */
87+
TABLE* table() const { return mariadb_table; }
88+
89+
/** Set the table handle for evaluating virtual columns.
90+
@param[in] table table handle */
91+
void set_table(TABLE* table)
92+
{
93+
ut_ad(!table || is_first_fetch());
94+
mariadb_table = table;
95+
}
96+
97+
/** Note that virtual column information may be needed. */
98+
void set_requested()
99+
{
100+
ut_ad(!used);
101+
ut_ad(!first_use);
102+
ut_ad(!mariadb_table);
103+
requested = true;
104+
}
105+
106+
/** @return whether the virtual column information may be needed */
107+
bool is_requested() const { return requested; }
108+
84109
/** Note that the virtual column information is needed. */
85110
void set_used()
86111
{
@@ -97,11 +122,22 @@ struct purge_vcol_info_t
97122
}
98123
}
99124

125+
/** @return whether the virtual column information is needed */
126+
bool is_used() const
127+
{
128+
ut_ad(!first_use || used);
129+
ut_ad(!used || requested);
130+
ut_ad(used || !mariadb_table);
131+
return used;
132+
}
133+
100134
/** Check whether it fetches mariadb table for the first time.
101135
@return true if first time tries to open mariadb table. */
102136
bool is_first_fetch() const
103137
{
104138
ut_ad(!first_use || used);
139+
ut_ad(!used || requested);
140+
ut_ad(used || !mariadb_table);
105141
return first_use;
106142
}
107143
};

storage/innobase/row/row0purge.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ row_purge_remove_clust_if_poss_low(
137137
rec_offs_init(offsets_);
138138

139139
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
140-
|| node->vcol_info.used);
140+
|| node->vcol_info.is_used());
141141

142142
index = dict_table_get_first_index(node->table);
143143

@@ -250,7 +250,7 @@ static void row_purge_store_vsec_cur(
250250
return;
251251
}
252252

253-
node->vcol_info.requested = true;
253+
node->vcol_info.set_requested();
254254

255255
btr_pcur_store_position(sec_pcur, sec_mtr);
256256

@@ -318,7 +318,7 @@ row_purge_poss_sec(
318318

319319
ut_ad(!dict_index_is_clust(index));
320320

321-
const bool store_cur = sec_mtr && !node->vcol_info.used
321+
const bool store_cur = sec_mtr && !node->vcol_info.is_used()
322322
&& dict_index_has_virtual(index);
323323

324324
if (store_cur) {
@@ -327,7 +327,7 @@ row_purge_poss_sec(
327327
/* The PRIMARY KEY value was not found in the clustered
328328
index. The secondary index record found. We can purge
329329
the secondary index record. */
330-
if (!node->vcol_info.requested) {
330+
if (!node->vcol_info.is_requested()) {
331331
ut_ad(!node->found_clust);
332332
return true;
333333
}
@@ -344,7 +344,9 @@ row_purge_poss_sec(
344344
&node->vcol_info);
345345

346346
if (node->vcol_info.is_first_fetch()) {
347-
if (node->vcol_info.mariadb_table) {
347+
ut_ad(store_cur);
348+
349+
if (node->vcol_info.table()) {
348350
node->vcol_info.set_used();
349351
goto retry_purge_sec;
350352
}
@@ -801,7 +803,7 @@ row_purge_upd_exist_or_extern_func(
801803
mem_heap_t* heap;
802804

803805
ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_S)
804-
|| node->vcol_info.used);
806+
|| node->vcol_info.is_used());
805807
ut_ad(!node->table->skip_alter_undo);
806808

807809
if (node->rec_type == TRX_UNDO_UPD_DEL_REC
@@ -1139,7 +1141,7 @@ row_purge(
11391141
bool purged = row_purge_record(
11401142
node, undo_rec, thr, updated_extern);
11411143

1142-
if (!node->vcol_info.used) {
1144+
if (!node->vcol_info.is_used()) {
11431145
rw_lock_s_unlock(dict_operation_lock);
11441146
}
11451147

storage/innobase/row/row0vers.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ row_vers_build_clust_v_col(
457457

458458
if (vcol_info != NULL) {
459459
vcol_info->set_used();
460-
maria_table = vcol_info->mariadb_table;
460+
maria_table = vcol_info->table();
461461
}
462462

463463
innobase_allocate_row_for_vcol(thd, index,
@@ -466,9 +466,8 @@ row_vers_build_clust_v_col(
466466
&record,
467467
&vcol_storage);
468468

469-
if (vcol_info && !vcol_info->mariadb_table) {
470-
vcol_info->mariadb_table = maria_table;
471-
ut_ad(!maria_table || vcol_info->is_first_fetch());
469+
if (vcol_info && !vcol_info->table()) {
470+
vcol_info->set_table(maria_table);
472471
goto func_exit;
473472
}
474473

@@ -834,7 +833,7 @@ row_vers_build_cur_vrow(
834833
rec, *clust_offsets,
835834
NULL, NULL, NULL, NULL, heap);
836835

837-
if (vcol_info && !vcol_info->used) {
836+
if (vcol_info && !vcol_info->is_used()) {
838837
mtr->commit();
839838
}
840839

@@ -955,7 +954,7 @@ row_vers_old_has_index_entry(
955954
if (trx_undo_roll_ptr_is_insert(t_roll_ptr)
956955
|| dbug_v_purge) {
957956

958-
if (vcol_info && !vcol_info->used) {
957+
if (vcol_info && !vcol_info->is_used()) {
959958
mtr->commit();
960959
}
961960

0 commit comments

Comments
 (0)