Commit 498f84a8 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12353: Remove mlog_open_and_write_index()

Now that all logical log records have been replaced,
the function mlog_parse_index() is only needed for crash-upgrading
from older versions.
parent 08ba3887
...@@ -211,26 +211,10 @@ mlog_parse_string( ...@@ -211,26 +211,10 @@ mlog_parse_string(
or NULL */ or NULL */
void* page_zip);/*!< in/out: compressed page, or NULL */ void* page_zip);/*!< in/out: compressed page, or NULL */
/********************************************************//**
Opens a buffer for mlog, writes the initial log record and,
if needed, the field lengths of an index. Reserves space
for further log entries. The log entry must be closed with
mtr_close().
@return buffer, NULL if log mode MTR_LOG_NONE */
byte*
mlog_open_and_write_index(
/*======================*/
mtr_t* mtr, /*!< in: mtr */
const byte* rec, /*!< in: index record or page */
const dict_index_t* index, /*!< in: record descriptor */
mlog_id_t type, /*!< in: log item type */
ulint size); /*!< in: requested buffer size in bytes
(if 0, calls mlog_close() and
returns NULL) */
/********************************************************//** /********************************************************//**
Parses a log record written by mlog_open_and_write_index. Parses a log record written by mlog_open_and_write_index.
@return parsed record end, NULL if not a complete record */ @return parsed record end, NULL if not a complete record */
ATTRIBUTE_COLD /* only used when crash-upgrading */
const byte* const byte*
mlog_parse_index( mlog_parse_index(
/*=============*/ /*=============*/
......
...@@ -379,129 +379,10 @@ void mtr_t::memset(const buf_block_t* b, ulint ofs, ulint len, byte val) ...@@ -379,129 +379,10 @@ void mtr_t::memset(const buf_block_t* b, ulint ofs, ulint len, byte val)
mlog_close(this, l + 5); mlog_close(this, l + 5);
} }
/********************************************************//**
Opens a buffer for mlog, writes the initial log record and,
if needed, the field lengths of an index.
@return buffer, NULL if log mode MTR_LOG_NONE */
byte*
mlog_open_and_write_index(
/*======================*/
mtr_t* mtr, /*!< in: mtr */
const byte* rec, /*!< in: index record or page */
const dict_index_t* index, /*!< in: record descriptor */
mlog_id_t type, /*!< in: log item type */
ulint size) /*!< in: requested buffer size in bytes
(if 0, calls mlog_close() and
returns NULL) */
{
byte* log_ptr;
const byte* log_start;
const byte* log_end;
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
mtr->set_modified();
switch (mtr->get_log_mode()) {
case MTR_LOG_NONE:
case MTR_LOG_NO_REDO:
return NULL;
case MTR_LOG_ALL:
break;
}
if (!page_rec_is_comp(rec)) {
log_start = log_ptr = mtr->get_log()->open(11 + size);
log_ptr = mlog_write_initial_log_record_fast(rec, type,
log_ptr, mtr);
log_end = log_ptr + 11 + size;
} else {
ulint i;
bool is_instant = index->is_instant();
ulint n = dict_index_get_n_fields(index);
ulint total = 11 + (is_instant ? 2 : 0) + size + (n + 2) * 2;
ulint alloc = std::min(total,
ulint(mtr_buf_t::MAX_DATA_SIZE));
const bool is_leaf = page_is_leaf(page_align(rec));
/* For spatial index, on non-leaf page, we just keep
2 fields, MBR and page no. */
if (!is_leaf && dict_index_is_spatial(index)) {
n = DICT_INDEX_SPATIAL_NODEPTR_SIZE;
}
log_start = log_ptr = mtr->get_log()->open(alloc);
log_end = log_ptr + alloc;
log_ptr = mlog_write_initial_log_record_fast(
rec, type, log_ptr, mtr);
if (is_instant) {
// marked as instant index
mach_write_to_2(log_ptr, n | 0x8000);
log_ptr += 2;
// record the n_core_fields
mach_write_to_2(log_ptr, index->n_core_fields);
} else {
mach_write_to_2(log_ptr, n);
}
log_ptr += 2;
mach_write_to_2(
log_ptr, is_leaf
? dict_index_get_n_unique_in_tree(index)
: dict_index_get_n_unique_in_tree_nonleaf(index));
log_ptr += 2;
for (i = 0; i < n; i++) {
dict_field_t* field;
const dict_col_t* col;
ulint len;
field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(field);
len = field->fixed_len;
ut_ad(len < 0x7fff);
if (len == 0
&& (DATA_BIG_COL(col))) {
/* variable-length field
with maximum length > 255 */
len = 0x7fff;
}
if (col->prtype & DATA_NOT_NULL) {
len |= 0x8000;
}
if (log_ptr + 2 > log_end) {
mlog_close(mtr, log_ptr);
ut_a(total > ulint(log_ptr - log_start));
total -= ulint(log_ptr - log_start);
alloc = std::min(
total,
ulint(mtr_buf_t::MAX_DATA_SIZE));
log_start = log_ptr = mtr->get_log()->open(
alloc);
log_end = log_ptr + alloc;
}
mach_write_to_2(log_ptr, len);
log_ptr += 2;
}
}
if (size == 0) {
mlog_close(mtr, log_ptr);
log_ptr = NULL;
} else if (log_ptr + size > log_end) {
mlog_close(mtr, log_ptr);
log_ptr = mlog_open(mtr, size);
}
return(log_ptr);
}
/********************************************************//** /********************************************************//**
Parses a log record written by mlog_open_and_write_index. Parses a log record written by mlog_open_and_write_index.
@return parsed record end, NULL if not a complete record */ @return parsed record end, NULL if not a complete record */
ATTRIBUTE_COLD /* only used when crash-upgrading */
const byte* const byte*
mlog_parse_index( mlog_parse_index(
/*=============*/ /*=============*/
......
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