Skip to content

Commit

Permalink
MDEV-11369: Implement stricter checks for the metadata record
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Oct 3, 2018
1 parent 15c7225 commit c134f56
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions storage/innobase/btr/btr0cur.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,14 @@ 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()) {
return DB_SUCCESS;
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;
Expand All @@ -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;
}

Expand Down

0 comments on commit c134f56

Please sign in to comment.