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

Fix a rollback bug

row_rec_to_index_entry_impl<true, 2>(): Correctly convert a record
from instant ALTER TABLE format into instant ADD COLUMN format.

row_undo_search_clust_to_pcur(): Relax too tight debug assertions.
parent 3905ba7c
...@@ -725,27 +725,26 @@ row_rec_to_index_entry_impl( ...@@ -725,27 +725,26 @@ row_rec_to_index_entry_impl(
ut_ad(rec != NULL); ut_ad(rec != NULL);
ut_ad(heap != NULL); ut_ad(heap != NULL);
ut_ad(index != NULL); ut_ad(index != NULL);
ut_ad(!mblob || metadata);
ut_ad(!mblob || index->is_primary()); ut_ad(!mblob || index->is_primary());
ut_ad(!mblob || !dict_index_is_spatial(index)); ut_ad(!mblob || !dict_index_is_spatial(index));
compile_time_assert(!mblob || metadata);
compile_time_assert(mblob <= 2); compile_time_assert(mblob <= 2);
ut_ad(mblob != 2 || dtuple_t::is_metadata(info_bits));
ut_ad(mblob == 2 || info_bits == 0);
/* Because this function may be invoked by row0merge.cc /* Because this function may be invoked by row0merge.cc
on a record whose header is in different format, the check on a record whose header is in different format, the check
rec_offs_validate(rec, index, offsets) must be avoided here. */ rec_offs_validate(rec, index, offsets) must be avoided here. */
ut_ad(n_ext); ut_ad(n_ext);
*n_ext = 0; *n_ext = 0;
ut_ad(mblob != 2 const bool got = mblob == 2 && rec_is_alter_metadata(rec, *index);
|| rec_offs_n_fields(offsets) ulint rec_len = rec_offs_n_fields(offsets);
== ulint(index->n_fields + rec_is_alter_metadata(rec, *index))); if (mblob == 2) {
ut_ad(info_bits == REC_INFO_METADATA_ALTER
ulint rec_len = mblob == 2 || info_bits == REC_INFO_METADATA_ADD);
? ulint(index->n_fields ut_ad(rec_len <= ulint(index->n_fields + got));
+ (info_bits == REC_INFO_METADATA_ALTER)) rec_len += !got && info_bits == REC_INFO_METADATA_ALTER;
: rec_offs_n_fields(offsets); } else {
ut_ad(info_bits == 0);
}
dtuple_t* entry = dtuple_create(heap, rec_len); dtuple_t* entry = dtuple_create(heap, rec_len);
dfield_t* dfield = entry->fields; dfield_t* dfield = entry->fields;
...@@ -788,7 +787,6 @@ row_rec_to_index_entry_impl( ...@@ -788,7 +787,6 @@ row_rec_to_index_entry_impl(
ulint j = i; ulint j = i;
if (mblob == 2) { if (mblob == 2) {
const bool got = rec_is_alter_metadata(rec, *index);
const bool want = info_bits == REC_INFO_METADATA_ALTER; const bool want = info_bits == REC_INFO_METADATA_ALTER;
if (got == want) { if (got == want) {
if (got) { if (got) {
...@@ -837,6 +835,11 @@ row_rec_to_index_entry_impl( ...@@ -837,6 +835,11 @@ row_rec_to_index_entry_impl(
} }
} }
if (mblob == 2) {
ulint n_fields = ulint(dfield - entry->fields);
ut_ad(entry->n_fields >= n_fields);
entry->n_fields = n_fields;
}
ut_ad(dfield == entry->fields + entry->n_fields); ut_ad(dfield == entry->fields + entry->n_fields);
ut_ad(dtuple_check_typed(entry)); ut_ad(dtuple_check_typed(entry));
return entry; return entry;
......
...@@ -229,13 +229,15 @@ row_undo_search_clust_to_pcur( ...@@ -229,13 +229,15 @@ row_undo_search_clust_to_pcur(
} }
if (node->rec_type == TRX_UNDO_UPD_EXIST_REC) { if (node->rec_type == TRX_UNDO_UPD_EXIST_REC) {
ut_ad(node->row->info_bits == REC_INFO_MIN_REC_FLAG ut_ad((node->row->info_bits & ~REC_INFO_DELETED_FLAG)
== REC_INFO_MIN_REC_FLAG
|| node->row->info_bits == 0); || node->row->info_bits == 0);
node->undo_row = dtuple_copy(node->row, node->heap); node->undo_row = dtuple_copy(node->row, node->heap);
row_upd_replace(node->undo_row, &node->undo_ext, row_upd_replace(node->undo_row, &node->undo_ext,
clust_index, node->update, node->heap); clust_index, node->update, node->heap);
} else { } else {
ut_ad((node->row->info_bits == REC_INFO_MIN_REC_FLAG) ut_ad(((node->row->info_bits & ~REC_INFO_DELETED_FLAG)
== REC_INFO_MIN_REC_FLAG)
== (node->rec_type == TRX_UNDO_INSERT_METADATA)); == (node->rec_type == TRX_UNDO_INSERT_METADATA));
node->undo_row = NULL; node->undo_row = NULL;
node->undo_ext = NULL; node->undo_ext = NULL;
......
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