@@ -23551,53 +23551,32 @@ void innobase_rename_vc_templ(dict_table_t *table) {
23551
23551
table->vc_templ->tb_name.assign(table_name);
23552
23552
}
23553
23553
23554
- dfield_t *innobase_get_field_from_update_vector(dict_foreign_t *foreign,
23555
- upd_t *update,
23556
- uint32_t col_no) {
23557
- dict_table_t *parent_table = foreign->referenced_table;
23558
- dict_index_t *parent_index = foreign->referenced_index;
23559
- uint32_t parent_field_no;
23560
- uint32_t parent_col_no;
23561
- uint32_t child_col_no;
23562
-
23563
- for (uint32_t i = 0; i < foreign->n_fields; i++) {
23564
- child_col_no = foreign->foreign_index->get_col_no(i);
23565
- if (child_col_no != col_no) {
23566
- continue;
23567
- }
23568
- parent_col_no = parent_index->get_col_no(i);
23569
- parent_field_no = dict_table_get_nth_col_pos(parent_table, parent_col_no);
23570
- for (uint32_t j = 0; j < update->n_fields; j++) {
23571
- upd_field_t *parent_ufield = &update->fields[j];
23572
- if (parent_ufield->field_no == parent_field_no) {
23573
- return (&parent_ufield->new_val);
23574
- }
23554
+ /** Get the updated field value from an update vector for the given column
23555
+ number.
23556
+ @param[in] update the update vector for the table's clustered index
23557
+ @param[in] col_no the number of the non-virtual column in the table
23558
+ @return the field's new value if it's updated, otherwise nullptr */
23559
+ static const dfield_t *innobase_get_field_from_update_vector(
23560
+ const upd_t *update, uint32_t col_no) {
23561
+ const dict_table_t *const table = update->table;
23562
+ const dict_index_t *const clustered_index = table->first_index();
23563
+ const auto index_field_pos = clustered_index->get_col_pos(col_no);
23564
+
23565
+ for (uint32_t j = 0; j < update->n_fields; j++) {
23566
+ const upd_field_t *const ufield = &update->fields[j];
23567
+ if (ufield->field_no == index_field_pos) {
23568
+ return &ufield->new_val;
23575
23569
}
23576
23570
}
23577
23571
23578
23572
return (nullptr);
23579
23573
}
23580
23574
23581
- /** Get the computed value by supplying the base column values.
23582
- @param[in,out] row the data row
23583
- @param[in] col virtual column
23584
- @param[in] index index on the virtual column
23585
- @param[in,out] local_heap heap memory for processing large data etc.
23586
- @param[in,out] heap memory heap that copies the actual index row
23587
- @param[in] ifield index field
23588
- @param[in] thd MySQL thread handle
23589
- @param[in,out] mysql_table mysql table object
23590
- @param[in] old_table during ALTER TABLE, this is the old table
23591
- or NULL.
23592
- @param[in] parent_update update vector for the parent row
23593
- @param[in] foreign foreign key information
23594
- @return the field filled with computed value, or NULL if just want
23595
- to store the value in passed in "my_rec" */
23596
23575
dfield_t *innobase_get_computed_value(
23597
- const dtuple_t *row, const dict_v_col_t *col, const dict_index_t *index ,
23598
- mem_heap_t **local_heap, mem_heap_t *heap, const dict_field_t *ifield ,
23599
- THD *thd, TABLE *mysql_table , const dict_table_t *old_table,
23600
- upd_t *parent_update, dict_foreign_t *foreign ) {
23576
+ const dtuple_t *row, const dict_v_col_t *col, const dict_table_t *table ,
23577
+ mem_heap_t **local_heap, mem_heap_t *heap, THD *thd, TABLE *mysql_table ,
23578
+ const dict_field_t *ifield , const dict_table_t *old_table,
23579
+ upd_t *row_update ) {
23601
23580
byte rec_buf1[REC_VERSION_56_MAX_INDEX_COL_LEN];
23602
23581
byte rec_buf2[REC_VERSION_56_MAX_INDEX_COL_LEN];
23603
23582
byte *mysql_rec;
@@ -23607,36 +23586,27 @@ dfield_t *innobase_get_computed_value(
23607
23586
ulong mv_length = 0;
23608
23587
const char *mv_data_ptr = nullptr;
23609
23588
23610
- const page_size_t page_size = (old_table == nullptr)
23611
- ? dict_table_page_size(index->table)
23612
- : dict_table_page_size(old_table);
23613
-
23614
- const dict_index_t *clust_index = nullptr;
23615
- if (old_table == nullptr) {
23616
- clust_index = index->table->first_index();
23617
- } else {
23618
- clust_index = old_table->first_index();
23619
- }
23589
+ /* table definition to use for externally stored fields */
23590
+ const dict_table_t *const ext_src_table = (old_table ? old_table : table);
23591
+ const page_size_t page_size = dict_table_page_size(ext_src_table);
23620
23592
23621
23593
ulint ret = 0;
23622
23594
23623
- ut_ad(index-> table->vc_templ);
23595
+ ut_ad(table->vc_templ);
23624
23596
ut_ad(thd != nullptr);
23625
23597
23626
23598
const mysql_row_templ_t *vctempl =
23627
- index->table->vc_templ
23628
- ->vtempl[index->table->vc_templ->n_col + col->v_pos];
23599
+ table->vc_templ->vtempl[table->vc_templ->n_col + col->v_pos];
23629
23600
23630
- if (!heap ||
23631
- index->table->vc_templ->rec_len >= REC_VERSION_56_MAX_INDEX_COL_LEN) {
23601
+ if (!heap || table->vc_templ->rec_len >= REC_VERSION_56_MAX_INDEX_COL_LEN) {
23632
23602
if (*local_heap == nullptr) {
23633
23603
*local_heap = mem_heap_create(UNIV_PAGE_SIZE, UT_LOCATION_HERE);
23634
23604
}
23635
23605
23636
23606
mysql_rec = static_cast<byte *>(
23637
- mem_heap_alloc(*local_heap, index-> table->vc_templ->rec_len));
23607
+ mem_heap_alloc(*local_heap, table->vc_templ->rec_len));
23638
23608
buf = static_cast<byte *>(
23639
- mem_heap_alloc(*local_heap, index-> table->vc_templ->rec_len));
23609
+ mem_heap_alloc(*local_heap, table->vc_templ->rec_len));
23640
23610
} else {
23641
23611
mysql_rec = rec_buf1;
23642
23612
buf = rec_buf2;
@@ -23646,12 +23616,11 @@ dfield_t *innobase_get_computed_value(
23646
23616
dict_col_t *base_col = col->base_col[i];
23647
23617
const dfield_t *row_field = nullptr;
23648
23618
uint32_t col_no = base_col->ind;
23649
- const mysql_row_templ_t *templ = index-> table->vc_templ->vtempl[col_no];
23619
+ const mysql_row_templ_t *const templ = table->vc_templ->vtempl[col_no];
23650
23620
const byte *data;
23651
23621
23652
- if (parent_update != nullptr) {
23653
- row_field =
23654
- innobase_get_field_from_update_vector(foreign, parent_update, col_no);
23622
+ if (row_update != nullptr) {
23623
+ row_field = innobase_get_field_from_update_vector(row_update, col_no);
23655
23624
}
23656
23625
23657
23626
if (row_field == nullptr) {
@@ -23667,20 +23636,20 @@ dfield_t *innobase_get_computed_value(
23667
23636
}
23668
23637
23669
23638
data = lob::btr_copy_externally_stored_field(
23670
- thd_to_trx(thd), clust_index , &len, nullptr, data, page_size ,
23671
- dfield_get_len(row_field), false, *local_heap);
23639
+ thd_to_trx(thd), ext_src_table->first_index() , &len, nullptr, data,
23640
+ page_size, dfield_get_len(row_field), false, *local_heap);
23672
23641
}
23673
23642
23674
23643
if (len == UNIV_SQL_NULL) {
23675
23644
mysql_rec[templ->mysql_null_byte_offset] |=
23676
23645
(byte)templ->mysql_null_bit_mask;
23677
23646
memcpy(mysql_rec + templ->mysql_col_offset,
23678
- static_cast<const byte *>(index-> table->vc_templ->default_rec +
23647
+ static_cast<const byte *>(table->vc_templ->default_rec +
23679
23648
templ->mysql_col_offset),
23680
23649
templ->mysql_col_len);
23681
23650
} else {
23682
23651
row_sel_field_store_in_mysql_format(
23683
- mysql_rec + templ->mysql_col_offset, templ, index ,
23652
+ mysql_rec + templ->mysql_col_offset, templ, table->first_index() ,
23684
23653
templ->clust_rec_field_no, (const byte *)data, len, ULINT_UNDEFINED);
23685
23654
23686
23655
if (templ->mysql_null_bit_mask) {
@@ -23715,7 +23684,7 @@ dfield_t *innobase_get_computed_value(
23715
23684
only 1 byte, other BLOBs won't be affected */
23716
23685
max_len = 255;
23717
23686
} else {
23718
- max_len = DICT_MAX_FIELD_LEN_BY_FORMAT(index-> table) + 1;
23687
+ max_len = DICT_MAX_FIELD_LEN_BY_FORMAT(table) + 1;
23719
23688
}
23720
23689
23721
23690
byte *blob_mem = static_cast<byte *>(mem_heap_alloc(heap, max_len));
@@ -23725,8 +23694,8 @@ dfield_t *innobase_get_computed_value(
23725
23694
}
23726
23695
23727
23696
/* open a temporary table handle */
23728
- mysql_table = tblhdl.open(thd, index-> table->vc_templ->db_name.c_str(),
23729
- index-> table->vc_templ->tb_name.c_str());
23697
+ mysql_table = tblhdl.open(thd, table->vc_templ->db_name.c_str(),
23698
+ table->vc_templ->tb_name.c_str());
23730
23699
}
23731
23700
if (mysql_table) {
23732
23701
ret = handler::my_eval_gcolumn_expr(
@@ -23763,8 +23732,8 @@ dfield_t *innobase_get_computed_value(
23763
23732
json_binary::Value v(json_binary::parse_binary(mv_data_ptr, mv_length));
23764
23733
multi_value_data *value = nullptr;
23765
23734
23766
- bool succ = innobase_store_multi_value(
23767
- v, value, fld, field, dict_table_is_comp(index-> table), heap);
23735
+ bool succ = innobase_store_multi_value(v, value, fld, field,
23736
+ dict_table_is_comp(table), heap);
23768
23737
if (!succ) {
23769
23738
ut_error;
23770
23739
}
@@ -23773,7 +23742,7 @@ dfield_t *innobase_get_computed_value(
23773
23742
} else {
23774
23743
row_mysql_store_col_in_innobase_format(
23775
23744
field, buf, true, mysql_rec + vctempl->mysql_col_offset,
23776
- vctempl->mysql_col_len, dict_table_is_comp(index-> table));
23745
+ vctempl->mysql_col_len, dict_table_is_comp(table));
23777
23746
}
23778
23747
field->type.prtype |= DATA_VIRTUAL;
23779
23748
0 commit comments