Skip to content

Commit ebafe5a

Browse files
committed
Cleanup: Avoid repeated calls to dict_col_t::is_virtual()
1 parent 4a165f3 commit ebafe5a

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5775,14 +5775,13 @@ innobase_vcol_build_templ(
57755775
mysql_row_templ_t* templ,
57765776
ulint col_no)
57775777
{
5778-
if (dict_col_is_virtual(col)) {
5779-
templ->is_virtual = true;
5780-
templ->col_no = col_no;
5778+
templ->col_no = col_no;
5779+
templ->is_virtual = col->is_virtual();
5780+
5781+
if (templ->is_virtual) {
57815782
templ->clust_rec_field_no = ULINT_UNDEFINED;
57825783
templ->rec_field_no = col->ind;
57835784
} else {
5784-
templ->is_virtual = false;
5785-
templ->col_no = col_no;
57865785
templ->clust_rec_field_no = dict_col_get_clust_pos(
57875786
col, clust_index);
57885787
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);

storage/innobase/row/row0merge.cc

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -554,23 +554,16 @@ row_merge_buf_add(
554554

555555
for (i = 0; i < n_fields; i++, field++, ifield++) {
556556
ulint len;
557-
const dict_col_t* col;
558-
ulint col_no;
559557
ulint fixed_len;
560558
const dfield_t* row_field;
561-
562-
col = ifield->col;
563-
const dict_v_col_t* v_col = NULL;
564-
if (dict_col_is_virtual(col)) {
565-
v_col = reinterpret_cast<const dict_v_col_t*>(col);
566-
}
567-
568-
col_no = dict_col_get_no(col);
559+
const dict_col_t* const col = ifield->col;
560+
const dict_v_col_t* const v_col = col->is_virtual()
561+
? reinterpret_cast<const dict_v_col_t*>(col)
562+
: NULL;
569563

570564
/* Process the Doc ID column */
571-
if (*doc_id > 0
572-
&& col_no == index->table->fts->doc_col
573-
&& !dict_col_is_virtual(col)) {
565+
if (!v_col && *doc_id
566+
&& col->ind == index->table->fts->doc_col) {
574567
fts_write_doc_id((byte*) &write_doc_id, *doc_id);
575568

576569
/* Note: field->data now points to a value on the
@@ -589,7 +582,7 @@ row_merge_buf_add(
589582
field->type.len = ifield->col->len;
590583
} else {
591584
/* Use callback to get the virtual column value */
592-
if (dict_col_is_virtual(col)) {
585+
if (v_col) {
593586
dict_index_t* clust_index
594587
= dict_table_get_first_index(new_table);
595588

@@ -614,7 +607,8 @@ row_merge_buf_add(
614607
}
615608
dfield_copy(field, row_field);
616609
} else {
617-
row_field = dtuple_get_nth_field(row, col_no);
610+
row_field = dtuple_get_nth_field(row,
611+
col->ind);
618612
dfield_copy(field, row_field);
619613
}
620614

@@ -720,7 +714,7 @@ row_merge_buf_add(
720714
} else if (!ext) {
721715
} else if (dict_index_is_clust(index)) {
722716
/* Flag externally stored fields. */
723-
const byte* buf = row_ext_lookup(ext, col_no,
717+
const byte* buf = row_ext_lookup(ext, col->ind,
724718
&len);
725719
if (UNIV_LIKELY_NULL(buf)) {
726720
ut_a(buf != field_ref_zero);
@@ -731,9 +725,9 @@ row_merge_buf_add(
731725
len = dfield_get_len(field);
732726
}
733727
}
734-
} else if (!dict_col_is_virtual(col)) {
728+
} else if (!v_col) {
735729
/* Only non-virtual column are stored externally */
736-
const byte* buf = row_ext_lookup(ext, col_no,
730+
const byte* buf = row_ext_lookup(ext, col->ind,
737731
&len);
738732
if (UNIV_LIKELY_NULL(buf)) {
739733
ut_a(buf != field_ref_zero);

0 commit comments

Comments
 (0)