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

MDEV-11369: Implement stricter checks for the metadata record

btr_cur_instant_init_low(): If columns were instantly added and dropped,
then index->is_instant() might not hold even though the root page type
was FIL_PAGE_TYPE_INSTANT. MariaDB 10.3 must refuse to open such files,
because instant DROP COLUMN is not supported.

Also, refuse to open the table if the metadata record has
wrong info OR status bits. Previously, we only refused to open
if both bits were wrong.
parent 15c7225a
......@@ -413,8 +413,15 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
ut_ad(index->n_core_null_bytes != dict_index_t::NO_CORE_NULL_BYTES);
if (!index->is_instant()) {
if (fil_page_get_type(root) == FIL_PAGE_INDEX) {
return DB_SUCCESS;
}
incompatible:
ib::error() << "Table " << index->table->name
<< " contains unrecognizable instant ALTER metadata";
index->table->corrupted = true;
return DB_CORRUPTION;
}
btr_cur_t cur;
dberr_t err = btr_cur_open_at_index_side(true, index, BTR_SEARCH_LEAF,
......@@ -430,25 +437,19 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
page_cur_move_to_next(&cur.page_cur);
const rec_t* rec = cur.page_cur.rec;
const ulint comp = dict_table_is_comp(index->table);
const ulint info_bits = rec_get_info_bits(rec, comp);
if (page_rec_is_supremum(rec) || !rec_is_metadata(rec, index)) {
if (page_rec_is_supremum(rec)
|| !(info_bits & REC_INFO_MIN_REC_FLAG)) {
ib::error() << "Table " << index->table->name
<< " is missing instant ALTER metadata";
index->table->corrupted = true;
return DB_CORRUPTION;
}
if (dict_table_is_comp(index->table)) {
if (rec_get_info_bits(rec, true) != REC_INFO_MIN_REC_FLAG
&& rec_get_status(rec) != REC_STATUS_COLUMNS_ADDED) {
incompatible:
ib::error() << "Table " << index->table->name
<< " contains unrecognizable "
"instant ALTER metadata";
index->table->corrupted = true;
return DB_CORRUPTION;
}
} else if (rec_get_info_bits(rec, false) != REC_INFO_MIN_REC_FLAG) {
if (info_bits != REC_INFO_MIN_REC_FLAG
|| (comp && rec_get_status(rec) != REC_STATUS_COLUMNS_ADDED)) {
goto incompatible;
}
......
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