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

MDEV-11369: Implement accurate checks for the metadata record

Because changes of the FIL_PAGE_TYPE or PAGE_INSTANT in the root
page are not undo-logged, it is possible that the fields suggest
that instant ADD COLUMN is in effect, even though no metadata
record exists. If the fields are set, proceed to fetch the
metadata record. If the metadata record does not exist, return
success if !index->is_instant().

Also, check that the "infimum" and "supremum" records carry the
strings in the root page. In a later format that supports instant
DROP COLUMN, we will have to store more information in the root
page, so that index->n_core_null_bytes can be determined accurately.
parent c134f565
...@@ -412,10 +412,15 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr) ...@@ -412,10 +412,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); 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) {
if (fil_page_get_type(root) == FIL_PAGE_INDEX) { ut_ad(!index->is_instant());
return DB_SUCCESS; return DB_SUCCESS;
} }
/* In a later format, these fields in a FIL_PAGE_TYPE_INSTANT
root page could be repurposed for something else. */
if (memcmp(page_get_infimum_rec(root), "infimum", 8)
|| memcmp(page_get_supremum_rec(root), "supremum", 8)) {
incompatible: incompatible:
ib::error() << "Table " << index->table->name ib::error() << "Table " << index->table->name
<< " contains unrecognizable instant ALTER metadata"; << " contains unrecognizable instant ALTER metadata";
...@@ -442,6 +447,17 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr) ...@@ -442,6 +447,17 @@ btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
if (page_rec_is_supremum(rec) if (page_rec_is_supremum(rec)
|| !(info_bits & REC_INFO_MIN_REC_FLAG)) { || !(info_bits & REC_INFO_MIN_REC_FLAG)) {
if (!index->is_instant()) {
/* The FIL_PAGE_TYPE_INSTANT and PAGE_INSTANT may be
assigned even if instant ADD COLUMN was not
committed. Changes to these page header fields are not
undo-logged, but changes to the hidden metadata record
are. If the server is killed and restarted, the page
header fields could remain set even though no metadata
record is present. */
return DB_SUCCESS;
}
ib::error() << "Table " << index->table->name ib::error() << "Table " << index->table->name
<< " is missing instant ALTER metadata"; << " is missing instant ALTER metadata";
index->table->corrupted = true; index->table->corrupted = true;
......
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