Commit 6e82d5b4 authored by Marko Mäkelä's avatar Marko Mäkelä

When rolling back the initial instant ADD COLUMN, restore the root page to non-instant format

parent 3b229393
...@@ -1138,6 +1138,7 @@ page_set_instant(page_t* page, unsigned n, mtr_t* mtr) ...@@ -1138,6 +1138,7 @@ page_set_instant(page_t* page, unsigned n, mtr_t* mtr)
ut_ad(n > 0); ut_ad(n > 0);
ut_ad(n < 1U << 10); ut_ad(n < 1U << 10);
uint16_t i = page_header_get_field(page, PAGE_INSTANT); uint16_t i = page_header_get_field(page, PAGE_INSTANT);
ut_ad(i <= PAGE_NO_DIRECTION);
i |= n << 6; i |= n << 6;
mlog_write_ulint(PAGE_HEADER + PAGE_INSTANT + page, i, mlog_write_ulint(PAGE_HEADER + PAGE_INSTANT + page, i,
MLOG_2BYTES, mtr); MLOG_2BYTES, mtr);
......
...@@ -78,6 +78,7 @@ row_undo_ins_remove_clust_rec( ...@@ -78,6 +78,7 @@ row_undo_ins_remove_clust_rec(
mtr.start(); mtr.start();
if (index->table->is_temporary()) { if (index->table->is_temporary()) {
ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
mtr.set_log_mode(MTR_LOG_NO_REDO); mtr.set_log_mode(MTR_LOG_NO_REDO);
} else { } else {
mtr.set_named_space(index->space); mtr.set_named_space(index->space);
...@@ -122,9 +123,9 @@ row_undo_ins_remove_clust_rec( ...@@ -122,9 +123,9 @@ row_undo_ins_remove_clust_rec(
switch (node->table->id) { switch (node->table->id) {
case DICT_INDEXES_ID: case DICT_INDEXES_ID:
ut_ad(!online); ut_ad(!online);
ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH); ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
dict_drop_index_tree( dict_drop_index_tree(
btr_pcur_get_rec(&node->pcur), &(node->pcur), &mtr); btr_pcur_get_rec(&node->pcur), &(node->pcur), &mtr);
...@@ -145,6 +146,7 @@ row_undo_ins_remove_clust_rec( ...@@ -145,6 +146,7 @@ row_undo_ins_remove_clust_rec(
been rolled back. */ been rolled back. */
ut_ad(!online); ut_ad(!online);
ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH); ut_ad(node->trx->dict_operation_lock_mode == RW_X_LATCH);
ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
const rec_t* rec = btr_pcur_get_rec(&node->pcur); const rec_t* rec = btr_pcur_get_rec(&node->pcur);
if (rec_get_n_fields_old(rec) if (rec_get_n_fields_old(rec)
!= DICT_NUM_FIELDS__SYS_COLUMNS) { != DICT_NUM_FIELDS__SYS_COLUMNS) {
...@@ -254,6 +256,27 @@ row_undo_ins_remove_clust_rec( ...@@ -254,6 +256,27 @@ row_undo_ins_remove_clust_rec(
func_exit: func_exit:
btr_pcur_commit_specify_mtr(&node->pcur, &mtr); btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
if (err == DB_SUCCESS && node->rec_type == TRX_UNDO_INSERT_DEFAULT) {
/* When rolling back the very first instant ADD COLUMN
operation, reset the root page to the basic state. */
ut_ad(!index->table->is_temporary());
mtr.start();
if (page_t* root = btr_root_get(index, &mtr)) {
byte* page_type = root + FIL_PAGE_TYPE;
ut_ad(mach_read_from_2(page_type)
== FIL_PAGE_TYPE_INSTANT
|| mach_read_from_2(page_type)
== FIL_PAGE_INDEX);
mtr.set_named_space(index->space);
mlog_write_ulint(page_type, FIL_PAGE_INDEX,
MLOG_2BYTES, &mtr);
byte* instant = PAGE_INSTANT + PAGE_HEADER + root;
mlog_write_ulint(instant,
page_ptr_get_direction(instant + 1),
MLOG_2BYTES, &mtr);
}
mtr.commit();
}
return(err); return(err);
} }
...@@ -567,6 +590,11 @@ row_undo_ins( ...@@ -567,6 +590,11 @@ row_undo_ins(
node->index = dict_table_get_first_index(node->table); node->index = dict_table_get_first_index(node->table);
ut_ad(dict_index_is_clust(node->index)); ut_ad(dict_index_is_clust(node->index));
switch (node->rec_type) {
default:
ut_ad(!"wrong undo record type");
case TRX_UNDO_INSERT_REC:
/* Skip the clustered index (the first index) */ /* Skip the clustered index (the first index) */
node->index = dict_table_get_next_index(node->index); node->index = dict_table_get_next_index(node->index);
...@@ -574,11 +602,16 @@ row_undo_ins( ...@@ -574,11 +602,16 @@ row_undo_ins(
err = row_undo_ins_remove_sec_rec(node, thr); err = row_undo_ins_remove_sec_rec(node, thr);
if (err == DB_SUCCESS) { if (err != DB_SUCCESS) {
break;
}
/* fall through */
case TRX_UNDO_INSERT_DEFAULT:
log_free_check(); log_free_check();
if (node->table->id == DICT_INDEXES_ID) { if (node->table->id == DICT_INDEXES_ID) {
ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
if (!dict_locked) { if (!dict_locked) {
mutex_enter(&dict_sys->mutex); mutex_enter(&dict_sys->mutex);
......
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