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

MDEV-12266: Add dict_index_t::set_modified(mtr)

This is a non-functional change (pure refactoring).
parent 39cbba19
......@@ -62,8 +62,8 @@ PageBulk::init()
because we don't guarantee pages are committed following
the allocation order, and we will always generate redo log
for page allocation, even when creating a new tablespace. */
mtr_start(&alloc_mtr);
alloc_mtr.set_named_space(dict_index_get_space(m_index));
alloc_mtr.start();
m_index->set_modified(alloc_mtr);
ulint n_reserved;
bool success;
......@@ -84,7 +84,7 @@ PageBulk::init()
n_reserved);
}
mtr_commit(&alloc_mtr);
alloc_mtr.commit();
new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block);
......@@ -963,9 +963,9 @@ BtrBulk::finish(dberr_t err)
root_page_no, m_root_level,
m_flush_observer);
mtr_start(&mtr);
mtr.set_named_space(dict_index_get_space(m_index));
mtr_x_lock(dict_index_get_lock(m_index), &mtr);
mtr.start();
m_index->set_modified(mtr);
mtr_x_lock(&m_index->lock, &mtr);
ut_ad(last_page_no != FIL_NULL);
last_block = btr_block_get(page_id, page_size,
......@@ -977,7 +977,7 @@ BtrBulk::finish(dberr_t err)
/* Copy last page to root page. */
err = root_page_bulk.init();
if (err != DB_SUCCESS) {
mtr_commit(&mtr);
mtr.commit();
return(err);
}
root_page_bulk.copyIn(first_rec);
......@@ -988,7 +988,7 @@ BtrBulk::finish(dberr_t err)
/* Do not flush the last page. */
last_block->page.flush_observer = NULL;
mtr_commit(&mtr);
mtr.commit();
err = pageCommit(&root_page_bulk, NULL, false);
ut_ad(err == DB_SUCCESS);
......
......@@ -7073,7 +7073,7 @@ struct btr_blob_log_check_t {
const mtr_log_t log_mode = m_mtr->get_log_mode();
m_mtr->start();
m_mtr->set_log_mode(log_mode);
m_mtr->set_named_space(index->space);
index->set_modified(*m_mtr);
m_mtr->set_flush_observer(observer);
if (m_op == BTR_STORE_INSERT_BULK) {
......@@ -7276,8 +7276,8 @@ btr_store_big_rec_extern_fields(
rec_page_no = rec_block->page.id.page_no();
}
mtr_start(&mtr);
mtr.set_named_space(index->space);
mtr.start();
index->set_modified(mtr);
mtr.set_log_mode(btr_mtr->get_log_mode());
mtr.set_flush_observer(btr_mtr->get_flush_observer());
......@@ -7293,7 +7293,7 @@ btr_store_big_rec_extern_fields(
mtr_t *alloc_mtr;
if (op == BTR_STORE_INSERT_BULK) {
mtr_start(&mtr_bulk);
mtr_bulk.start();
mtr_bulk.set_spaces(mtr);
alloc_mtr = &mtr_bulk;
} else {
......@@ -7304,7 +7304,7 @@ btr_store_big_rec_extern_fields(
FSP_BLOB, alloc_mtr,
1)) {
mtr_commit(alloc_mtr);
alloc_mtr->commit();
error = DB_OUT_OF_FILE_SPACE;
goto func_exit;
}
......@@ -7315,7 +7315,7 @@ btr_store_big_rec_extern_fields(
alloc_mtr->release_free_extents(r_extents);
if (op == BTR_STORE_INSERT_BULK) {
mtr_commit(&mtr_bulk);
mtr_bulk.commit();
}
ut_a(block != NULL);
......@@ -7542,7 +7542,7 @@ btr_store_big_rec_extern_fields(
prev_page_no = page_no;
mtr_commit(&mtr);
mtr.commit();
if (extern_len == 0) {
break;
......
......@@ -799,7 +799,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
mtr_start(&mtr);
cursor = btr_pcur_get_btr_cur(pcur);
index = btr_cur_get_index(cursor);
mtr.set_named_space(index->space);
index->set_modified(mtr);
/* To follow the latching order defined in WL#6326, acquire index->lock X-latch.
This entitles us to acquire page latches in any order for the index. */
mtr_x_lock(&index->lock, &mtr);
......
......@@ -822,14 +822,7 @@ dict_create_index_tree_step(
the index and its root address is written to the index entry in
sys_indexes */
mtr_start(&mtr);
const bool missing = !index->is_readable()
|| dict_table_is_discarded(index->table);
if (!missing) {
mtr.set_named_space(index->space);
}
mtr.start();
search_tuple = dict_create_search_tuple(node->ind_row, node->heap);
......@@ -842,9 +835,11 @@ dict_create_index_tree_step(
dberr_t err = DB_SUCCESS;
if (missing) {
if (!index->is_readable() || dict_table_is_discarded(index->table)) {
node->page_no = FIL_NULL;
} else {
index->set_modified(mtr);
node->page_no = btr_create(
index->type, index->space,
dict_table_page_size(index->table),
......@@ -865,7 +860,7 @@ dict_create_index_tree_step(
btr_pcur_close(&pcur);
mtr_commit(&mtr);
mtr.commit();
return(err);
}
......
......@@ -1894,16 +1894,16 @@ rtr_estimate_n_rows_in_range(
page_t* page;
ulint n_recs;
mtr_start(&mtr);
mtr.set_named_space(dict_index_get_space(index));
mtr_s_lock(dict_index_get_lock(index), &mtr);
mtr.start();
index->set_modified(mtr);
mtr_s_lock(&index->lock, &mtr);
block = btr_block_get(page_id, page_size, RW_S_LATCH, index, &mtr);
page = buf_block_get_frame(block);
n_recs = page_header_get_field(page, PAGE_N_RECS);
if (n_recs == 0) {
mtr_commit(&mtr);
mtr.commit();
return(HA_POS_ERROR);
}
......@@ -1987,7 +1987,7 @@ rtr_estimate_n_rows_in_range(
rec = page_rec_get_next(rec);
}
mtr_commit(&mtr);
mtr.commit();
mem_heap_free(heap);
if (!isfinite(area)) {
......
......@@ -4267,7 +4267,7 @@ innobase_add_instant_try(
mtr_t mtr;
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_pcur_t pcur;
btr_pcur_open_at_index_side(true, index, BTR_MODIFY_TREE, &pcur, true,
0, &mtr);
......@@ -4340,7 +4340,7 @@ innobase_add_instant_try(
ut_ad(user_table->is_instant());
mtr.commit();
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
dberr_t err;
if (page_t* root = btr_root_get(index, &mtr)) {
switch (fil_page_get_type(root)) {
......@@ -4364,7 +4364,7 @@ innobase_add_instant_try(
page_set_instant(root, index->n_core_fields, &mtr);
mtr.commit();
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
err = row_ins_clust_index_entry_low(
BTR_NO_LOCKING_FLAG, BTR_MODIFY_TREE, index,
index->n_uniq, entry, 0, thr, false);
......
......@@ -1060,6 +1060,10 @@ struct dict_index_t{
uncommitted = !committed;
}
/** Notify that the index pages are going to be modified.
@param[in,out] mtr mini-transaction */
inline void set_modified(mtr_t& mtr) const;
/** @return whether this index is readable
@retval true normally
@retval false if this is a single-table tablespace
......@@ -1944,6 +1948,11 @@ struct dict_table_t {
dict_vcol_templ_t* vc_templ;
};
inline void dict_index_t::set_modified(mtr_t& mtr) const
{
mtr.set_named_space(space);
}
inline bool dict_index_t::is_readable() const
{
return(UNIV_LIKELY(!table->file_unreadable));
......
......@@ -409,7 +409,7 @@ row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic)
mtr->set_log_mode(MTR_LOG_NO_REDO);
break;
default:
mtr->set_named_space(index->space);
index->set_modified(*mtr);
break;
}
......
......@@ -2471,7 +2471,7 @@ row_ins_index_entry_big_rec(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE,
......@@ -2565,7 +2565,7 @@ row_ins_clust_index_entry_low(
ut_ad(!index->is_instant());
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (mode == BTR_MODIFY_LEAF
&& dict_index_is_online_ddl(index)) {
......@@ -2801,8 +2801,8 @@ row_ins_sec_mtr_start_and_check_if_aborted(
const mtr_log_t log_mode = mtr->get_log_mode();
mtr_start(mtr);
mtr->set_named_space(index->space);
mtr->start();
index->set_modified(*mtr);
mtr->set_log_mode(log_mode);
if (!check) {
......@@ -2884,7 +2884,7 @@ row_ins_sec_index_entry_low(
ut_ad(flags & BTR_NO_LOCKING_FLAG);
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (!dict_index_is_spatial(index)) {
search_mode |= BTR_INSERT;
}
......@@ -2937,7 +2937,7 @@ row_ins_sec_index_entry_low(
index, false);
rtr_info_update_btr(&cursor, &rtr_info);
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
search_mode &= ulint(~BTR_MODIFY_LEAF);
search_mode |= BTR_MODIFY_TREE;
err = btr_cur_search_to_nth_level(
......
......@@ -1832,8 +1832,8 @@ row_log_table_apply_delete_low(
const dtuple_t* entry = row_build_index_entry(
row, save_ext, index, heap);
mtr_start(mtr);
mtr->set_named_space(index->space);
mtr->start();
index->set_modified(*mtr);
btr_pcur_open(index, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE,
pcur, mtr);
......@@ -1860,14 +1860,14 @@ row_log_table_apply_delete_low(
found, because new_table is being modified by
this thread only, and all indexes should be
updated in sync. */
mtr_commit(mtr);
mtr->commit();
return(DB_INDEX_CORRUPT);
}
btr_cur_pessimistic_delete(&error, FALSE,
btr_pcur_get_btr_cur(pcur),
BTR_CREATE_FLAG, false, mtr);
mtr_commit(mtr);
mtr->commit();
}
return(error);
......@@ -1919,7 +1919,7 @@ row_log_table_apply_delete(
}
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_pcur_open(index, old_pk, PAGE_CUR_LE,
BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE,
&pcur, &mtr);
......@@ -2067,7 +2067,7 @@ row_log_table_apply_update(
}
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_pcur_open(index, old_pk, PAGE_CUR_LE,
BTR_MODIFY_TREE, &pcur, &mtr);
#ifdef UNIV_DEBUG
......@@ -2327,7 +2327,7 @@ row_log_table_apply_update(
}
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (ROW_FOUND != row_search_index_entry(
index, entry, BTR_MODIFY_TREE, &pcur, &mtr)) {
......@@ -2359,7 +2359,7 @@ row_log_table_apply_update(
}
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
goto func_exit;
......@@ -3296,7 +3296,7 @@ row_log_apply_op_low(
<< rec_printer(entry).str());
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
/* We perform the pessimistic variant of the operations if we
already hold index->lock exclusively. First, search the
......@@ -3353,7 +3353,7 @@ row_log_apply_op_low(
Lock the index tree exclusively. */
mtr_commit(&mtr);
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE, &cursor, 0,
......@@ -3456,7 +3456,7 @@ row_log_apply_op_low(
Lock the index tree exclusively. */
mtr_commit(&mtr);
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE, &cursor, 0,
......
......@@ -165,7 +165,7 @@ class index_tuple_info_t {
}
mtr.start();
mtr.set_named_space(m_index->space);
m_index->set_modified(mtr);
ins_cur.index = m_index;
rtr_init_rtr_info(&rtr_info, false, &ins_cur, m_index,
......@@ -187,7 +187,7 @@ class index_tuple_info_t {
m_index, false);
rtr_info_update_btr(&ins_cur, &rtr_info);
mtr_start(&mtr);
mtr.set_named_space(m_index->space);
m_index->set_modified(mtr);
btr_cur_search_to_nth_level(
m_index, 0, dtuple,
PAGE_CUR_RTREE_INSERT,
......@@ -203,7 +203,7 @@ class index_tuple_info_t {
ut_ad(!big_rec);
mtr.commit();
mtr.start();
mtr.set_named_space(m_index->space);
m_index->set_modified(mtr);
rtr_clean_rtr_info(&rtr_info, true);
rtr_init_rtr_info(&rtr_info, false,
......
......@@ -142,7 +142,7 @@ row_purge_remove_clust_if_poss_low(
log_free_check();
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (!row_purge_reposition_pcur(mode, node, &mtr)) {
/* The record was already removed. */
......@@ -295,7 +295,7 @@ row_purge_remove_sec_if_poss_tree(
log_free_check();
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (!index->is_committed()) {
/* The index->online_status may change if the index is
......@@ -416,7 +416,7 @@ row_purge_remove_sec_if_poss_leaf(
ut_ad(index->table == node->table);
ut_ad(!dict_table_is_temporary(index->table));
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (!index->is_committed()) {
/* For uncommitted spatial index, we also skip the purge. */
......@@ -709,7 +709,7 @@ row_purge_reset_trx_id(purge_node_t* node, mtr_t* mtr)
<< ib::hex(row_get_rec_trx_id(
rec, index, offsets)));
mtr->set_named_space(index->space);
index->set_modified(*mtr);
if (page_zip_des_t* page_zip
= buf_block_get_page_zip(
btr_pcur_get_block(&node->pcur))) {
......@@ -830,7 +830,7 @@ row_purge_upd_exist_or_extern_func(
mtr_sx_lock(dict_index_get_lock(index), &mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
/* NOTE: we must also acquire an X-latch to the
root page of the tree. We will need it when we
......
/*****************************************************************************
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -81,7 +81,7 @@ row_undo_ins_remove_clust_rec(
ut_ad(node->rec_type == TRX_UNDO_INSERT_REC);
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
/* This is similar to row_undo_mod_clust(). The DDL thread may
......@@ -199,7 +199,7 @@ row_undo_ins_remove_clust_rec(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
success = btr_pcur_restore_position(
......@@ -238,7 +238,7 @@ row_undo_ins_remove_clust_rec(
== FIL_PAGE_TYPE_INSTANT
|| mach_read_from_2(page_type)
== FIL_PAGE_INDEX);
mtr.set_named_space(index->space);
index->set_modified(mtr);
mlog_write_ulint(page_type, FIL_PAGE_INDEX,
MLOG_2BYTES, &mtr);
byte* instant = PAGE_INSTANT + PAGE_HEADER + root;
......
......@@ -276,7 +276,7 @@ row_undo_mod_clust(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
online = dict_index_is_online_ddl(index);
......@@ -310,7 +310,7 @@ row_undo_mod_clust(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
err = row_undo_mod_clust_low(
......@@ -370,7 +370,7 @@ row_undo_mod_clust(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
/* It is not necessary to call row_log_table,
......@@ -388,7 +388,7 @@ row_undo_mod_clust(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
err = row_undo_mod_remove_clust_low(
......
......@@ -2319,7 +2319,7 @@ row_upd_sec_index_entry(
flags = BTR_NO_LOCKING_FLAG;
break;
default:
mtr.set_named_space(index->space);
index->set_modified(mtr);
/* fall through */
case IBUF_SPACE_ID:
flags = index->table->no_rollback() ? BTR_NO_ROLLBACK : 0;
......@@ -2881,7 +2881,7 @@ row_upd_clust_rec(
flags |= BTR_NO_LOCKING_FLAG;
mtr->set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr->set_named_space(index->space);
index->set_modified(*mtr);
}
/* NOTE: this transaction has an s-lock or x-lock on the record and
......@@ -3072,7 +3072,7 @@ row_upd_clust_step(
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
flags = node->table->no_rollback() ? BTR_NO_ROLLBACK : 0;
mtr.set_named_space(index->space);
index->set_modified(mtr);
}
/* If the restoration does not succeed, then the same
......@@ -3124,7 +3124,7 @@ row_upd_clust_step(
mtr.commit();
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
success = btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur,
&mtr);
......
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