summaryrefslogtreecommitdiff
path: root/storage/innobase/row/row0upd.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-26 12:02:07 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-26 12:02:07 +0300
commit97a4a3872e5037b8db1e8c27152740190330ab9c (patch)
tree4ac50bc687f7f1e55f4d4ff25e8a96555501e2bf /storage/innobase/row/row0upd.cc
parent8f8f2aea93835899345454f87768fd649749e29c (diff)
parent1e08e08ccb8896c1f0d2f673c16f5b92cdf7dc46 (diff)
downloadmariadb-git-97a4a3872e5037b8db1e8c27152740190330ab9c.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'storage/innobase/row/row0upd.cc')
-rw-r--r--storage/innobase/row/row0upd.cc134
1 files changed, 66 insertions, 68 deletions
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 2639f3ec7ea..7c8d5601352 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -821,7 +821,9 @@ containing also the reference to the external part
@param[in,out] len input - length of prefix to
fetch; output: fetched length of the prefix
@param[in,out] heap heap where to allocate
-@return BLOB prefix */
+@return BLOB prefix
+@retval NULL if the record is incomplete (should only happen
+in row_vers_vc_matches_cluster() executed concurrently with another purge) */
static
byte*
row_upd_ext_fetch(
@@ -836,10 +838,7 @@ row_upd_ext_fetch(
*len = btr_copy_externally_stored_field_prefix(
buf, *len, zip_size, data, local_len);
- /* We should never update records containing a half-deleted BLOB. */
- ut_a(*len);
-
- return(buf);
+ return *len ? buf : NULL;
}
/** Replaces the new column value stored in the update vector in
@@ -850,9 +849,11 @@ the given index entry field.
@param[in] uf update field
@param[in,out] heap memory heap for allocating and copying
the new value
-@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 */
+@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
+@return whether the previous version was built successfully */
+MY_ATTRIBUTE((nonnull, warn_unused_result))
static
-void
+bool
row_upd_index_replace_new_col_val(
dfield_t* dfield,
const dict_field_t* field,
@@ -867,13 +868,13 @@ row_upd_index_replace_new_col_val(
dfield_copy_data(dfield, &uf->new_val);
if (dfield_is_null(dfield)) {
- return;
+ return true;
}
len = dfield_get_len(dfield);
data = static_cast<const byte*>(dfield_get_data(dfield));
- if (field && field->prefix_len > 0) {
+ if (field->prefix_len > 0) {
ibool fetch_ext = dfield_is_ext(dfield)
&& len < (ulint) field->prefix_len
+ BTR_EXTERN_FIELD_REF_SIZE;
@@ -885,6 +886,9 @@ row_upd_index_replace_new_col_val(
data = row_upd_ext_fetch(data, l, zip_size,
&len, heap);
+ if (UNIV_UNLIKELY(!data)) {
+ return false;
+ }
}
len = dtype_get_at_most_n_mbchars(col->prtype,
@@ -898,7 +902,7 @@ row_upd_index_replace_new_col_val(
dfield_dup(dfield, heap);
}
- return;
+ return true;
}
switch (uf->orig_len) {
@@ -937,6 +941,8 @@ row_upd_index_replace_new_col_val(
dfield_set_ext(dfield);
break;
}
+
+ return true;
}
/** Apply an update vector to an metadata entry.
@@ -983,8 +989,11 @@ row_upd_index_replace_metadata(
f -= f > first;
const dict_field_t* field = dict_index_get_nth_field(index, f);
- row_upd_index_replace_new_col_val(dfield, field, field->col,
- uf, heap, zip_size);
+ if (!row_upd_index_replace_new_col_val(dfield, field,
+ field->col,
+ uf, heap, zip_size)) {
+ ut_error;
+ }
}
ut_ad(found_mblob);
@@ -1035,69 +1044,58 @@ row_upd_index_replace_new_col_vals_index_pos(
update, i, false);
}
- if (uf) {
- row_upd_index_replace_new_col_val(
- dtuple_get_nth_field(entry, i),
- field, col, uf, heap, zip_size);
+ if (uf && UNIV_UNLIKELY(!row_upd_index_replace_new_col_val(
+ dtuple_get_nth_field(entry, i),
+ field, col, uf, heap,
+ zip_size))) {
+ ut_error;
}
}
}
-/***********************************************************//**
-Replaces the new column values stored in the update vector to the index entry
-given. */
-void
-row_upd_index_replace_new_col_vals(
-/*===============================*/
- dtuple_t* entry, /*!< in/out: index entry where replaced;
- the clustered index record must be
- covered by a lock or a page latch to
- prevent deletion (rollback or purge) */
- dict_index_t* index, /*!< in: index; NOTE that this may also be a
- non-clustered index */
- const upd_t* update, /*!< in: an update vector built for the
- CLUSTERED index so that the field number in
- an upd_field is the clustered index position */
- mem_heap_t* heap) /*!< in: memory heap for allocating and
- copying the new values */
+/** Replace the new column values stored in the update vector,
+during trx_undo_prev_version_build().
+@param entry clustered index tuple where the values are replaced
+ (the clustered index leaf page latch must be held)
+@param index clustered index
+@param update update vector for the clustered index
+@param heap memory heap for allocating and copying values
+@return whether the previous version was built successfully */
+bool
+row_upd_index_replace_new_col_vals(dtuple_t *entry, const dict_index_t &index,
+ const upd_t *update, mem_heap_t *heap)
{
- ulint i;
- const dict_index_t* clust_index
- = dict_table_get_first_index(index->table);
- const ulint zip_size = index->table->space->zip_size();
+ ut_ad(index.is_primary());
+ const ulint zip_size= index.table->space->zip_size();
- ut_ad(!index->table->skip_alter_undo);
+ ut_ad(!index.table->skip_alter_undo);
+ dtuple_set_info_bits(entry, update->info_bits);
- dtuple_set_info_bits(entry, update->info_bits);
-
- for (i = 0; i < dict_index_get_n_fields(index); i++) {
- const dict_field_t* field;
- const dict_col_t* col;
- const upd_field_t* uf;
-
- field = dict_index_get_nth_field(index, i);
- col = dict_field_get_col(field);
- if (col->is_virtual()) {
- const dict_v_col_t* vcol = reinterpret_cast<
- const dict_v_col_t*>(
- col);
-
- uf = upd_get_field_by_field_no(
- update, vcol->v_pos, true);
- } else {
- uf = upd_get_field_by_field_no(
- update, static_cast<uint16_t>(
- dict_col_get_clust_pos(
- col, clust_index)),
- false);
- }
+ for (ulint i= 0; i < index.n_fields; i++)
+ {
+ const dict_field_t *field= &index.fields[i];
+ const dict_col_t* col= dict_field_get_col(field);
+ const upd_field_t *uf;
+
+ if (col->is_virtual())
+ {
+ const dict_v_col_t *vcol= reinterpret_cast<const dict_v_col_t*>(col);
+ uf= upd_get_field_by_field_no(update, vcol->v_pos, true);
+ }
+ else
+ uf= upd_get_field_by_field_no(update, static_cast<uint16_t>
+ (dict_col_get_clust_pos(col, &index)),
+ false);
+
+ if (!uf)
+ continue;
+
+ if (!row_upd_index_replace_new_col_val(dtuple_get_nth_field(entry, i),
+ field, col, uf, heap, zip_size))
+ return false;
+ }
- if (uf) {
- row_upd_index_replace_new_col_val(
- dtuple_get_nth_field(entry, i),
- field, col, uf, heap, zip_size);
- }
- }
+ return true;
}
/** Replaces the virtual column values stored in the update vector.
@@ -2114,7 +2112,7 @@ row_upd_sec_index_entry(
#ifdef UNIV_DEBUG
mtr_commit(&mtr);
mtr_start(&mtr);
- ut_ad(btr_validate_index(index, 0));
+ ut_ad(btr_validate_index(index, 0) == DB_SUCCESS);
ut_ad(0);
#endif /* UNIV_DEBUG */
break;