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

Fix CHECK TABLE

btr_index_rec_validate(): Recognize the metadata record.
parent 54b7267c
...@@ -4749,14 +4749,32 @@ btr_index_rec_validate( ...@@ -4749,14 +4749,32 @@ btr_index_rec_validate(
return(FALSE); return(FALSE);
} }
const bool is_alter_metadata = page_is_leaf(page)
&& !page_has_prev(page)
&& index->is_primary() && index->table->instant
&& rec == page_rec_get_next_const(page_get_infimum_rec(page));
if (is_alter_metadata
&& !rec_is_alter_metadata(rec, page_is_comp(page))) {
btr_index_rec_validate_report(page, rec, index);
ib::error() << "First record is not ALTER TABLE metadata";
return FALSE;
}
if (!page_is_comp(page)) { if (!page_is_comp(page)) {
const ulint n_rec_fields = rec_get_n_fields_old(rec); const ulint n_rec_fields = rec_get_n_fields_old(rec);
if (n_rec_fields == DICT_FLD__SYS_INDEXES__MERGE_THRESHOLD if (n_rec_fields == DICT_FLD__SYS_INDEXES__MERGE_THRESHOLD
&& index->id == DICT_INDEXES_ID) { && index->id == DICT_INDEXES_ID) {
/* A record for older SYS_INDEXES table /* A record for older SYS_INDEXES table
(missing merge_threshold column) is acceptable. */ (missing merge_threshold column) is acceptable. */
} else if (is_alter_metadata) {
if (n_rec_fields != ulint(index->n_fields) + 1) {
goto n_field_mismatch;
}
} else if (n_rec_fields < index->n_core_fields } else if (n_rec_fields < index->n_core_fields
|| n_rec_fields > index->n_fields) { || n_rec_fields > index->n_fields) {
n_field_mismatch:
btr_index_rec_validate_report(page, rec, index); btr_index_rec_validate_report(page, rec, index);
ib::error() << "Has " << rec_get_n_fields_old(rec) ib::error() << "Has " << rec_get_n_fields_old(rec)
...@@ -4775,15 +4793,28 @@ btr_index_rec_validate( ...@@ -4775,15 +4793,28 @@ btr_index_rec_validate(
offsets = rec_get_offsets(rec, index, offsets, page_is_leaf(page), offsets = rec_get_offsets(rec, index, offsets, page_is_leaf(page),
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
const dict_field_t* field = index->fields;
ut_ad(rec_offs_n_fields(offsets)
== ulint(index->n_fields) + is_alter_metadata);
for (unsigned i = 0; i < index->n_fields; i++) { for (unsigned i = 0; i < rec_offs_n_fields(offsets); i++) {
dict_field_t* field = dict_index_get_nth_field(index, i);
ulint fixed_size = dict_col_get_fixed_size(
dict_field_get_col(field),
page_is_comp(page));
rec_get_nth_field_offs(offsets, i, &len); rec_get_nth_field_offs(offsets, i, &len);
ulint fixed_size;
if (is_alter_metadata && i == index->first_user_field()) {
fixed_size = FIELD_REF_SIZE;
if (len != FIELD_REF_SIZE
|| !rec_offs_nth_extern(offsets, i)) {
goto len_mismatch;
}
continue;
} else {
fixed_size = dict_col_get_fixed_size(
field->col, page_is_comp(page));
}
/* Note that if fixed_size != 0, it equals the /* Note that if fixed_size != 0, it equals the
length of a fixed-size column in the clustered index. length of a fixed-size column in the clustered index.
We should adjust it here. We should adjust it here.
...@@ -4795,8 +4826,8 @@ btr_index_rec_validate( ...@@ -4795,8 +4826,8 @@ btr_index_rec_validate(
&& (field->prefix_len && (field->prefix_len
? len > field->prefix_len ? len > field->prefix_len
: (fixed_size && len != fixed_size))) { : (fixed_size && len != fixed_size))) {
len_mismatch:
btr_index_rec_validate_report(page, rec, index); btr_index_rec_validate_report(page, rec, index);
ib::error error; ib::error error;
error << "Field " << i << " len is " << len error << "Field " << i << " len is " << len
...@@ -4814,6 +4845,8 @@ btr_index_rec_validate( ...@@ -4814,6 +4845,8 @@ btr_index_rec_validate(
} }
return(FALSE); return(FALSE);
} }
field++;
} }
#ifdef VIRTUAL_INDEX_DEBUG #ifdef VIRTUAL_INDEX_DEBUG
......
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