Commit 770231f3 authored by Marko Mäkelä's avatar Marko Mäkelä

Remove dict_disable_redo_if_temporary()

The function dict_disable_redo_if_temporary() was supposed to
disable redo logging for temporary tables. It was invoked
unnecessarily for two read-only operations:
row_undo_search_clust_to_pcur() and
dict_stats_update_transient_for_index().

When a table is not temporary and not in the system tablespace,
the tablespace should be flagged for MLOG_FILE_NAME logging.
We do not need this overhead for temporary tables. Therefore,
either mtr_t::set_log_mode() or mtr_t::set_named_space() should
be invoked.

dict_table_t::is_temporary(): Determine if a table is temporary.

dict_table_is_temporary(): Redefined as a macro wrapper for
dict_table_t::is_temporary().

dict_disable_redo_if_temporary(): Remove.
parent 387bdf07
......@@ -79,7 +79,9 @@ dict_hdr_get_new_id(
mtr_start(&mtr);
if (table) {
dict_disable_redo_if_temporary(table, &mtr);
if (table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
}
} else if (disable_redo) {
/* In non-read-only mode we need to ensure that space-id header
page is written to disk else if page is removed from buffer
......@@ -87,8 +89,8 @@ dict_hdr_get_new_id(
to another tablespace.
This is not a case with read-only mode as there is no new object
that is created except temporary tablespace. */
mtr_set_log_mode(&mtr,
(srv_read_only_mode ? MTR_LOG_NONE : MTR_LOG_NO_REDO));
mtr.set_log_mode(srv_read_only_mode
? MTR_LOG_NONE : MTR_LOG_NO_REDO);
}
/* Server started and let's say space-id = x
......
......@@ -887,7 +887,6 @@ dict_stats_update_transient_for_index(
ulint size;
mtr_start(&mtr);
dict_disable_redo_if_temporary(index->table, &mtr);
mtr_s_lock(dict_index_get_lock(index), &mtr);
......
......@@ -1946,24 +1946,7 @@ dict_table_is_discarded(
const dict_table_t* table) /*!< in: table to check */
MY_ATTRIBUTE((warn_unused_result));
/********************************************************************//**
Check if it is a temporary table.
@return true if temporary table flag is set. */
UNIV_INLINE
bool
dict_table_is_temporary(
/*====================*/
const dict_table_t* table) /*!< in: table to check */
MY_ATTRIBUTE((warn_unused_result));
/********************************************************************//**
Turn-off redo-logging if temporary table. */
UNIV_INLINE
void
dict_disable_redo_if_temporary(
/*===========================*/
const dict_table_t* table, /*!< in: table to check */
mtr_t* mtr); /*!< out: mini-transaction */
#define dict_table_is_temporary(table) (table)->is_temporary()
/*********************************************************************//**
This function should be called whenever a page is successfully
......
......@@ -1524,32 +1524,6 @@ dict_table_is_discarded(
return(DICT_TF2_FLAG_IS_SET(table, DICT_TF2_DISCARDED));
}
/********************************************************************//**
Check if it is a temporary table.
@return true if temporary table flag is set. */
UNIV_INLINE
bool
dict_table_is_temporary(
/*====================*/
const dict_table_t* table) /*!< in: table to check */
{
return(DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY));
}
/********************************************************************//**
Turn-off redo-logging if temporary table. */
UNIV_INLINE
void
dict_disable_redo_if_temporary(
/*===========================*/
const dict_table_t* table, /*!< in: table to check */
mtr_t* mtr) /*!< out: mini-transaction */
{
if (dict_table_is_temporary(table)) {
mtr_set_log_mode(mtr, MTR_LOG_NO_REDO);
}
}
/** Check if the table is found is a file_per_table tablespace.
This test does not use table flags2 since some REDUNDANT tables in the
system tablespace may have garbage in the MIX_LEN field where flags2 is
......
......@@ -1311,6 +1311,12 @@ struct dict_table_t {
/** Release the table handle. */
inline void release();
/** @return whether this is a temporary table */
bool is_temporary() const
{
return flags2 & DICT_TF2_TEMPORARY;
}
/** @return whether this table is readable
@retval true normally
@retval false if this is a single-table tablespace
......
......@@ -2487,9 +2487,12 @@ row_ins_index_entry_big_rec(
DEBUG_SYNC_C_IF_THD(thd, "before_row_ins_extern_latch");
mtr_start(&mtr);
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
mtr.start();
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE,
&pcur, &mtr);
......@@ -2508,7 +2511,7 @@ row_ins_index_entry_big_rec(
index, offsets);
}
mtr_commit(&mtr);
mtr.commit();
btr_pcur_close(&pcur);
......
......@@ -76,9 +76,12 @@ row_undo_ins_remove_clust_rec(
ut_ad(dict_index_is_clust(index));
ut_ad(node->trx->in_rollback);
mtr_start(&mtr);
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
mtr.start();
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
/* This is similar to row_undo_mod_clust(). The DDL thread may
already have copied this row from the log to the new table.
......@@ -125,9 +128,9 @@ row_undo_ins_remove_clust_rec(
dict_drop_index_tree(
btr_pcur_get_rec(&node->pcur), &(node->pcur), &mtr);
mtr_commit(&mtr);
mtr.commit();
mtr_start(&mtr);
mtr.start();
success = btr_pcur_restore_position(
BTR_MODIFY_LEAF, &node->pcur, &mtr);
......@@ -142,9 +145,12 @@ row_undo_ins_remove_clust_rec(
btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
retry:
/* If did not succeed, try pessimistic descent to tree */
mtr_start(&mtr);
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
mtr.start();
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
success = btr_pcur_restore_position(
BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE,
......
......@@ -272,9 +272,12 @@ row_undo_mod_clust(
pcur = &node->pcur;
index = btr_cur_get_index(btr_pcur_get_btr_cur(pcur));
mtr_start(&mtr);
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
mtr.start();
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
online = dict_index_is_online_ddl(index);
if (online) {
......@@ -304,8 +307,11 @@ row_undo_mod_clust(
descent down the index tree */
mtr_start_trx(&mtr, thr_get_trx(thr));
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
err = row_undo_mod_clust_low(
node, &offsets, &offsets_heap,
......@@ -363,8 +369,11 @@ row_undo_mod_clust(
if (err == DB_SUCCESS && node->rec_type == TRX_UNDO_UPD_DEL_REC) {
mtr_start_trx(&mtr, thr_get_trx(thr));
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
/* It is not necessary to call row_log_table,
because the record is delete-marked and would thus
......@@ -378,8 +387,11 @@ row_undo_mod_clust(
pessimistic descent down the index tree */
mtr_start_trx(&mtr, thr_get_trx(thr));
mtr.set_named_space(index->space);
dict_disable_redo_if_temporary(index->table, &mtr);
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
}
err = row_undo_mod_remove_clust_low(
node, &mtr,
......
......@@ -172,7 +172,6 @@ row_undo_search_clust_to_pcur(
rec_offs_init(offsets_);
mtr_start(&mtr);
dict_disable_redo_if_temporary(node->table, &mtr);
clust_index = dict_table_get_first_index(node->table);
......
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