Commit 39d8652c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13564 follow-up: Remove unused code

DropIndex, CreateIndex: Remove. The file row0trunc.cc only exists
in MariaDB Server 10.3 so that the crash recovery of TRUNCATE TABLE
operations from older 10.2 and 10.3 servers will work. This dead code
was being used for implementing the MySQL 5.7 WL#6501 TRUNCATE TABLE
that was replaced with a backup-safe implementation in MDEV-13564.
parent 613e1307
...@@ -440,68 +440,6 @@ TruncateLogParser::scan_and_parse( ...@@ -440,68 +440,6 @@ TruncateLogParser::scan_and_parse(
return(err); return(err);
} }
/** Callback to drop indexes during TRUNCATE */
class DropIndex : public Callback {
public:
/**
Constructor
@param[in,out] table Table to truncate
@param[in,out] trx dictionary transaction
@param[in] noredo whether to disable redo logging */
DropIndex(dict_table_t* table, trx_t* trx, bool noredo)
: Callback(table->id, noredo), m_trx(trx), m_table(table) {}
/**
@param mtr mini-transaction covering the read
@param pcur persistent cursor used for reading
@return DB_SUCCESS or error code */
dberr_t operator()(mtr_t* mtr, btr_pcur_t* pcur) const;
private:
/** dictionary transaction */
trx_t* const m_trx;
/** Table to be truncated */
dict_table_t* const m_table;
};
/** Callback to create the indexes during TRUNCATE */
class CreateIndex : public Callback {
public:
/**
Constructor
@param[in,out] table Table to truncate
@param[in] noredo whether to disable redo logging */
CreateIndex(dict_table_t* table, bool noredo)
:
Callback(table->id, noredo),
m_table(table)
{
/* No op */
}
/**
Create the new index and update the root page number in the
SysIndex table.
@param mtr mini-transaction covering the read
@param pcur persistent cursor used for reading
@return DB_SUCCESS or error code */
dberr_t operator()(mtr_t* mtr, btr_pcur_t* pcur) const;
private:
// Disably copying
CreateIndex(const CreateIndex&);
CreateIndex& operator=(const CreateIndex&);
private:
/** Table to be truncated */
dict_table_t* m_table;
};
/** Check for presence of table-id in SYS_XXXX tables. */ /** Check for presence of table-id in SYS_XXXX tables. */
class TableLocator : public Callback { class TableLocator : public Callback {
...@@ -540,161 +478,6 @@ class TableLocator : public Callback { ...@@ -540,161 +478,6 @@ class TableLocator : public Callback {
bool m_table_found; bool m_table_found;
}; };
/**
Drop an index in the table.
@param mtr mini-transaction covering the read
@param pcur persistent cursor used for reading
@return DB_SUCCESS or error code */
dberr_t
DropIndex::operator()(mtr_t* mtr, btr_pcur_t* pcur) const
{
rec_t* rec = btr_pcur_get_rec(pcur);
bool freed = dict_drop_index_tree(rec, pcur, m_trx, mtr);
#ifdef UNIV_DEBUG
{
ulint len;
const byte* field;
ulint index_type;
field = rec_get_nth_field_old(
btr_pcur_get_rec(pcur), DICT_FLD__SYS_INDEXES__TYPE,
&len);
ut_ad(len == 4);
index_type = mach_read_from_4(field);
if (index_type & DICT_CLUSTERED) {
/* Clustered index */
DBUG_EXECUTE_IF("ib_trunc_crash_on_drop_of_clust_index",
log_buffer_flush_to_disk();
os_thread_sleep(2000000);
DBUG_SUICIDE(););
} else if (index_type & DICT_UNIQUE) {
/* Unique index */
DBUG_EXECUTE_IF("ib_trunc_crash_on_drop_of_uniq_index",
log_buffer_flush_to_disk();
os_thread_sleep(2000000);
DBUG_SUICIDE(););
} else if (index_type == 0) {
/* Secondary index */
DBUG_EXECUTE_IF("ib_trunc_crash_on_drop_of_sec_index",
log_buffer_flush_to_disk();
os_thread_sleep(2000000);
DBUG_SUICIDE(););
}
}
#endif /* UNIV_DEBUG */
DBUG_EXECUTE_IF("ib_err_trunc_drop_index", return DB_ERROR;);
if (freed) {
/* We will need to commit and restart the
mini-transaction in order to avoid deadlocks.
The dict_drop_index_tree() call has freed
a page in this mini-transaction, and the rest
of this loop could latch another index page.*/
const mtr_log_t log_mode = mtr->get_log_mode();
mtr_commit(mtr);
mtr_start(mtr);
mtr->set_log_mode(log_mode);
btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, mtr);
} else {
if (!m_table->space) {
return DB_ERROR;
}
}
return(DB_SUCCESS);
}
/**
Create the new index and update the root page number in the
SysIndex table.
@param mtr mini-transaction covering the read
@param pcur persistent cursor used for reading
@return DB_SUCCESS or error code */
dberr_t
CreateIndex::operator()(mtr_t* mtr, btr_pcur_t* pcur) const
{
ulint root_page_no;
root_page_no = dict_recreate_index_tree(m_table, pcur, mtr);
#ifdef UNIV_DEBUG
{
ulint len;
const byte* field;
ulint index_type;
field = rec_get_nth_field_old(
btr_pcur_get_rec(pcur), DICT_FLD__SYS_INDEXES__TYPE,
&len);
ut_ad(len == 4);
index_type = mach_read_from_4(field);
if (index_type & DICT_CLUSTERED) {
/* Clustered index */
DBUG_EXECUTE_IF(
"ib_trunc_crash_on_create_of_clust_index",
log_buffer_flush_to_disk();
os_thread_sleep(2000000);
DBUG_SUICIDE(););
} else if (index_type & DICT_UNIQUE) {
/* Unique index */
DBUG_EXECUTE_IF(
"ib_trunc_crash_on_create_of_uniq_index",
log_buffer_flush_to_disk();
os_thread_sleep(2000000);
DBUG_SUICIDE(););
} else if (index_type == 0) {
/* Secondary index */
DBUG_EXECUTE_IF(
"ib_trunc_crash_on_create_of_sec_index",
log_buffer_flush_to_disk();
os_thread_sleep(2000000);
DBUG_SUICIDE(););
}
}
#endif /* UNIV_DEBUG */
DBUG_EXECUTE_IF("ib_err_trunc_create_index", return DB_ERROR;);
if (root_page_no != FIL_NULL) {
ulint len;
byte* data = rec_get_nth_field_old(
btr_pcur_get_rec(pcur),
DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
ut_ad(len == 4);
mlog_write_ulint(data, root_page_no, MLOG_4BYTES, mtr);
/* We will need to commit and restart the
mini-transaction in order to avoid deadlocks.
The dict_create_index_tree() call has allocated
a page in this mini-transaction, and the rest of
this loop could latch another index page. */
mtr_commit(mtr);
mtr_start(mtr);
btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, mtr);
} else {
if (!m_table->space) {
return(DB_ERROR);
}
}
return(DB_SUCCESS);
}
/** /**
Update system table to reflect new table id. Update system table to reflect new table id.
@param old_table_id old table id @param old_table_id old table id
......
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