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

MDEV-12353: Write log by mtr_t member functions only

mtr_t::log_write_low(): Replaces mlog_write_initial_log_record_low().

mtr_t::log_file_op(): Replaces fil_op_write_log().

mtr_t::free(): Write MLOG_INIT_FREE_PAGE.

mtr_t::init(): Write MLOG_INIT_FILE_PAGE2.

mtr_t::page_create(): Write record about the partial initialization
of an index page.

mlog_catenate_ulint(), mlog_catenate_string(),
mlog_open(), mlog_close(): Remove.
parent 8a039ee1
......@@ -44,6 +44,7 @@ Created 11/5/1995 Heikki Tuuri
#include "fil0fil.h"
#include "fil0crypt.h"
#include "buf0buddy.h"
#include "buf0dblwr.h"
#include "lock0lock.h"
#include "sync0rw.h"
#include "btr0sea.h"
......
......@@ -32,6 +32,7 @@ Created 11/11/1995 Heikki Tuuri
#include "buf0flu.h"
#include "buf0buf.h"
#include "buf0checksum.h"
#include "buf0dblwr.h"
#include "srv0start.h"
#include "srv0srv.h"
#include "page0zip.h"
......
......@@ -31,6 +31,7 @@ Modified Jan Lindström jan.lindstrom@mariadb.com
#ifdef UNIV_INNOCHECKSUM
# include "buf0buf.h"
#else
#include "buf0dblwr.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "mtr0mtr.h"
......
......@@ -1812,27 +1812,18 @@ fil_create_directory_for_tablename(
ut_free(path);
}
/** Write a log record about an operation on a tablespace file.
@param[in] type MLOG_FILE_NAME or MLOG_FILE_DELETE
or MLOG_FILE_CREATE2 or MLOG_FILE_RENAME2
@param[in] space_id tablespace identifier
@param[in] first_page_no first page number in the file
@param[in] path file path
@param[in] new_path if type is MLOG_FILE_RENAME2, the new name
@param[in] flags if type is MLOG_FILE_CREATE2, the space flags
@param[in,out] mtr mini-transaction */
static
void
fil_op_write_log(
mlog_id_t type,
ulint space_id,
ulint first_page_no,
const char* path,
const char* new_path,
ulint flags,
mtr_t* mtr)
/** Write a log record about a file operation.
@param type file operation
@param space_id tablespace identifier
@param first_page_no first page number in the file
@param path file path
@param new_path new file path for type=MLOG_FILE_RENAME2
@param flags tablespace flags for type=MLOG_FILE_CREATE2 */
inline void mtr_t::log_file_op(mlog_id_t type,
ulint space_id, ulint first_page_no,
const char *path, const char *new_path,
ulint flags)
{
byte* log_ptr;
ulint len;
ut_ad(first_page_no == 0 || type == MLOG_FILE_CREATE2);
......@@ -1844,16 +1835,13 @@ fil_op_write_log(
ut_ad(first_page_no /* trimming an undo tablespace */
|| !strcmp(&path[strlen(path) - strlen(DOT_IBD)], DOT_IBD));
log_ptr = mlog_open(mtr, 11 + 4 + 2 + 1);
if (log_ptr == NULL) {
/* Logging in mtr is switched off during crash recovery:
in that case mlog_open returns NULL */
set_modified();
if (m_log_mode != MTR_LOG_ALL) {
return;
}
log_ptr = mlog_write_initial_log_record_low(
type, space_id, first_page_no, log_ptr, mtr);
byte* log_ptr = log_write_low(type, page_id_t(space_id, first_page_no),
m_log.open(11 + 4 + 2 + 1));
if (type == MLOG_FILE_CREATE2) {
mach_write_to_4(log_ptr, flags);
......@@ -1867,23 +1855,22 @@ fil_op_write_log(
mach_write_to_2(log_ptr, len);
log_ptr += 2;
mlog_close(mtr, log_ptr);
m_log.close(log_ptr);
mlog_catenate_string(
mtr, reinterpret_cast<const byte*>(path), len);
m_log.push(reinterpret_cast<const byte*>(path), uint32_t(len));
switch (type) {
case MLOG_FILE_RENAME2:
ut_ad(strchr(new_path, OS_PATH_SEPARATOR) != NULL);
len = strlen(new_path) + 1;
log_ptr = mlog_open(mtr, 2 + len);
log_ptr = m_log.open(2 + len);
ut_a(log_ptr);
mach_write_to_2(log_ptr, len);
log_ptr += 2;
mlog_close(mtr, log_ptr);
m_log.close(log_ptr);
mlog_catenate_string(
mtr, reinterpret_cast<const byte*>(new_path), len);
m_log.push(reinterpret_cast<const byte*>(new_path),
uint32_t(len));
break;
case MLOG_FILE_NAME:
case MLOG_FILE_DELETE:
......@@ -1910,10 +1897,8 @@ fil_name_write_rename_low(
mtr_t* mtr)
{
ut_ad(!is_predefined_tablespace(space_id));
fil_op_write_log(
MLOG_FILE_RENAME2,
space_id, first_page_no, old_name, new_name, 0, mtr);
mtr->log_file_op(MLOG_FILE_RENAME2, space_id, first_page_no,
old_name, new_name);
}
/** Write redo log for renaming a file.
......@@ -1946,8 +1931,7 @@ fil_name_write(
const char* name,
mtr_t* mtr)
{
fil_op_write_log(
MLOG_FILE_NAME, space_id, first_page_no, name, NULL, 0, mtr);
mtr->log_file_op(MLOG_FILE_NAME, space_id, first_page_no, name);
}
/** Write MLOG_FILE_NAME for a file.
@param[in] space tablespace
......@@ -1962,7 +1946,7 @@ fil_name_write(
const fil_node_t* file,
mtr_t* mtr)
{
fil_name_write(space->id, first_page_no, file->name, mtr);
mtr->log_file_op(MLOG_FILE_NAME, space->id, first_page_no, file->name);
}
/** Replay a file rename operation if possible.
......@@ -2362,9 +2346,9 @@ fil_delete_tablespace(
to be gone. */
mtr_t mtr;
mtr_start(&mtr);
fil_op_write_log(MLOG_FILE_DELETE, id, 0, path, NULL, 0, &mtr);
mtr_commit(&mtr);
mtr.start();
mtr.log_file_op(MLOG_FILE_DELETE, id, 0, path);
mtr.commit();
/* Even if we got killed shortly after deleting the
tablespace file, the record must have already been
written to the redo log. */
......@@ -2450,8 +2434,8 @@ void fil_truncate_log(fil_space_t* space, ulint size, mtr_t* mtr)
for writing pages that are after the new end of the tablespace. */
ut_ad(UT_LIST_GET_LEN(space->chain) == 1);
const fil_node_t* file = UT_LIST_GET_FIRST(space->chain);
fil_op_write_log(MLOG_FILE_CREATE2, space->id, size, file->name,
NULL, space->flags & ~FSP_FLAGS_MEM_MASK, mtr);
mtr->log_file_op(MLOG_FILE_CREATE2, space->id, size, file->name,
nullptr, space->flags & ~FSP_FLAGS_MEM_MASK);
}
/*******************************************************************//**
......@@ -2944,9 +2928,8 @@ fil_ibd_create(
false, true);
mtr_t mtr;
mtr.start();
fil_op_write_log(
MLOG_FILE_CREATE2, space_id, 0, node->name,
NULL, space->flags & ~FSP_FLAGS_MEM_MASK, &mtr);
mtr.log_file_op(MLOG_FILE_CREATE2, space_id, 0, node->name,
nullptr, space->flags & ~FSP_FLAGS_MEM_MASK);
fil_name_write(space, 0, node, &mtr);
mtr.commit();
......
......@@ -1274,11 +1274,7 @@ static void fsp_free_page(fil_space_t* space, page_no_t offset, mtr_t* mtr)
return;
}
if (byte* log_ptr = mlog_open(mtr, 11)) {
log_ptr = mlog_write_initial_log_record_low(
MLOG_INIT_FREE_PAGE, space->id, offset, log_ptr, mtr);
mlog_close(mtr, log_ptr);
}
mtr->free(page_id_t(space->id, offset));
const ulint bit = offset % FSP_EXTENT_SIZE;
......
/*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2020, 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
......@@ -31,6 +32,7 @@ Refactored 2013-7-26 by Kevin Lewis
#include "mem0mem.h"
#include "os0file.h"
#include "row0mysql.h"
#include "buf0dblwr.h"
/** The server header file is included to access opt_initialize global variable.
If server passes the option for create/open DB to SE, we should remove such
......
......@@ -627,15 +627,7 @@ inline void fsp_init_file_page(
ut_d(space->modify_check(*mtr));
ut_ad(space->id == block->page.id.space());
fsp_apply_init_file_page(block);
if (byte* log_ptr = mlog_open(mtr, 11)) {
log_ptr = mlog_write_initial_log_record_low(
MLOG_INIT_FILE_PAGE2,
block->page.id.space(), block->page.id.page_no(),
log_ptr, mtr);
mlog_close(mtr, log_ptr);
block->page.init_on_flush = true;
}
mtr->init(block);
}
#ifndef UNIV_DEBUG
......
......@@ -33,52 +33,6 @@ Created 12/7/1995 Heikki Tuuri
// Forward declaration
struct dict_index_t;
/********************************************************//**
Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */
UNIV_INLINE
void
mlog_catenate_ulint(
/*================*/
mtr_buf_t* dyn_buf, /*!< in/out: buffer to write */
ulint val, /*!< in: value to write */
mlog_id_t type); /*!< in: type of value to write */
/********************************************************//**
Catenates 1 - 4 bytes to the mtr log. */
UNIV_INLINE
void
mlog_catenate_ulint(
/*================*/
mtr_t* mtr, /*!< in: mtr */
ulint val, /*!< in: value to write */
mlog_id_t type); /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
/********************************************************//**
Catenates n bytes to the mtr log. */
void
mlog_catenate_string(
/*=================*/
mtr_t* mtr, /*!< in: mtr */
const byte* str, /*!< in: string to write */
ulint len); /*!< in: string length */
/********************************************************//**
Opens a buffer to mlog. It must be closed with mlog_close.
@return buffer, NULL if log mode MTR_LOG_NONE */
UNIV_INLINE
byte*
mlog_open(
/*======*/
mtr_t* mtr, /*!< in: mtr */
ulint size); /*!< in: buffer size in bytes; MUST be
smaller than DYN_ARRAY_DATA_SIZE! */
/********************************************************//**
Closes a buffer opened to mlog. */
UNIV_INLINE
void
mlog_close(
/*=======*/
mtr_t* mtr, /*!< in: mtr */
byte* ptr); /*!< in: buffer space from ptr up was
not used */
/** Write 1, 2, 4, or 8 bytes to a file page.
@param[in] block file page
@param[in,out] ptr pointer in file page
......@@ -122,9 +76,10 @@ inline void mtr_t::write(const buf_block_t &block, byte *ptr, V val)
mach_write_to_8(ptr, val);
break;
}
byte *log_ptr= mlog_open(this, 11 + 2 + (l == 8 ? 9 : 5));
if (!log_ptr)
set_modified();
if (m_log_mode != MTR_LOG_ALL)
return;
byte *log_ptr= m_log.open(11 + 2 + (l == 8 ? 9 : 5));
if (l == 8)
log_write(block, ptr, static_cast<mlog_id_t>(l), log_ptr, uint64_t{val});
else
......@@ -156,24 +111,22 @@ void mtr_t::zmemcpy(buf_page_t *b, ulint offset, const void *str, ulint len)
zmemcpy(*b, offset, len);
}
/** Writes a log record about an operation.
@param[in] type redo log record type
@param[in] space_id tablespace identifier
@param[in] page_no page number
@param[in,out] log_ptr current end of mini-transaction log
@param[in,out] mtr mini-transaction
@return end of mini-transaction log */
UNIV_INLINE
byte*
mlog_write_initial_log_record_low(
mlog_id_t type,
ulint space_id,
ulint page_no,
byte* log_ptr,
mtr_t* mtr);
/** Initialize an entire page.
@param[in,out] b buffer page */
inline void mtr_t::init(buf_block_t *b)
{
if (m_log_mode != MTR_LOG_ALL)
{
ut_ad(m_log_mode == MTR_LOG_NONE || m_log_mode == MTR_LOG_NO_REDO);
return;
}
m_log.close(log_write_low(MLOG_INIT_FILE_PAGE2, b->page.id, m_log.open(11)));
b->page.init_on_flush= true;
}
/********************************************************//**
Parses an initial log record written by mlog_write_initial_log_record_low().
Parses an initial log record written by mtr_t::log_write_low().
@return parsed record end, NULL if not a complete record */
const byte*
mlog_parse_initial_log_record(
......@@ -219,6 +172,4 @@ mlog_parse_index(
bool comp, /*!< in: TRUE=compact record format */
dict_index_t** index); /*!< out, own: dummy index */
#include "mtr0log.ic"
#endif /* mtr0log_h */
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, 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
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
*****************************************************************************/
/**************************************************//**
@file include/mtr0log.ic
Mini-transaction logging routines
Created 12/7/1995 Heikki Tuuri
*******************************************************/
#include "buf0dblwr.h"
#include "fsp0types.h"
#include "mach0data.h"
#include "trx0types.h"
/********************************************************//**
Opens a buffer to mlog. It must be closed with mlog_close.
@return buffer, NULL if log mode MTR_LOG_NONE or MTR_LOG_NO_REDO */
UNIV_INLINE
byte*
mlog_open(
/*======*/
mtr_t* mtr, /*!< in: mtr */
ulint size) /*!< in: buffer size in bytes; MUST be
smaller than mtr_t::buf_t::MAX_DATA_SIZE! */
{
mtr->set_modified();
if (mtr_get_log_mode(mtr) == MTR_LOG_NONE
|| mtr_get_log_mode(mtr) == MTR_LOG_NO_REDO) {
return(NULL);
}
return(mtr->get_log()->open(size));
}
/********************************************************//**
Closes a buffer opened to mlog. */
UNIV_INLINE
void
mlog_close(
/*=======*/
mtr_t* mtr, /*!< in: mtr */
byte* ptr) /*!< in: buffer space from ptr up was not used */
{
ut_ad(mtr_get_log_mode(mtr) != MTR_LOG_NONE);
ut_ad(mtr_get_log_mode(mtr) != MTR_LOG_NO_REDO);
mtr->get_log()->close(ptr);
}
/********************************************************//**
Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */
UNIV_INLINE
void
mlog_catenate_ulint(
/*================*/
mtr_buf_t* mtr_buf, /*!< in/out: buffer to write */
ulint val, /*!< in: value to write */
mlog_id_t type) /*!< in: type of value to write */
{
compile_time_assert(MLOG_1BYTE == 1);
compile_time_assert(MLOG_2BYTES == 2);
compile_time_assert(MLOG_4BYTES == 4);
compile_time_assert(MLOG_8BYTES == 8);
byte* ptr = mtr_buf->push<byte*>(type);
switch (type) {
case MLOG_4BYTES:
mach_write_to_4(ptr, val);
break;
case MLOG_2BYTES:
mach_write_to_2(ptr, val);
break;
case MLOG_1BYTE:
mach_write_to_1(ptr, val);
break;
default:
ut_error;
}
}
/********************************************************//**
Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */
UNIV_INLINE
void
mlog_catenate_ulint(
/*================*/
mtr_t* mtr, /*!< in/out: mtr */
ulint val, /*!< in: value to write */
mlog_id_t type) /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */
{
if (mtr_get_log_mode(mtr) == MTR_LOG_NONE
|| mtr_get_log_mode(mtr) == MTR_LOG_NO_REDO) {
return;
}
mlog_catenate_ulint(mtr->get_log(), val, type);
}
/** Writes a log record about an operation.
@param[in] type redo log record type
@param[in] space_id tablespace identifier
@param[in] page_no page number
@param[in,out] log_ptr current end of mini-transaction log
@param[in,out] mtr mini-transaction
@return end of mini-transaction log */
UNIV_INLINE
byte*
mlog_write_initial_log_record_low(
mlog_id_t type,
ulint space_id,
ulint page_no,
byte* log_ptr,
mtr_t* mtr)
{
ut_ad(type <= MLOG_BIGGEST_TYPE);
ut_ad(type == MLOG_FILE_NAME
|| type == MLOG_FILE_DELETE
|| type == MLOG_FILE_CREATE2
|| type == MLOG_FILE_RENAME2
|| mtr->is_named_space(space_id));
mach_write_to_1(log_ptr, type);
log_ptr++;
log_ptr += mach_write_compressed(log_ptr, space_id);
log_ptr += mach_write_compressed(log_ptr, page_no);
mtr->added_rec();
return(log_ptr);
}
......@@ -46,10 +46,6 @@ savepoint. */
#define mtr_release_s_latch_at_savepoint(m, s, l) \
(m)->release_s_latch_at_savepoint((s), (l))
/** Get the logging mode of a mini-transaction.
@return logging mode: MTR_LOG_NONE, ... */
#define mtr_get_log_mode(m) (m)->get_log_mode()
/** Change the logging mode of a mini-transaction.
@return old mode */
#define mtr_set_log_mode(m, d) (m)->set_log_mode((d))
......@@ -375,9 +371,6 @@ struct mtr_t {
/** @return true if a record was added to the mini-transaction */
bool is_dirty() const { return m_made_dirty; }
/** Note that a record has been added to the log */
void added_rec() { ++m_n_log_recs; }
/** Get the buffered redo log of this mini-transaction.
@return redo log */
const mtr_buf_t* get_log() const { return &m_log; }
......@@ -452,7 +445,78 @@ struct mtr_t {
@param[in] val the data byte to write */
void memset(const buf_block_t* b, ulint ofs, ulint len, byte val);
/** Initialize an entire page.
@param[in,out] b buffer page */
void init(buf_block_t *b);
/** Free a page.
@param id page identifier */
void free(const page_id_t id) { log_page_write(id, MLOG_INIT_FREE_PAGE); }
/** Partly initialize a B-tree page.
@param id page identifier
@param comp false=ROW_FORMAT=REDUNDANT, true=COMPACT or DYNAMIC */
void page_create(const page_id_t id, bool comp)
{
set_modified();
log_page_write(id, comp ? MLOG_COMP_PAGE_CREATE : MLOG_PAGE_CREATE);
}
/** Write a log record about a file operation.
@param type file operation
@param space_id tablespace identifier
@param first_page_no first page number in the file
@param path file path
@param new_path new file path for type=MLOG_FILE_RENAME2
@param flags tablespace flags for type=MLOG_FILE_CREATE2 */
inline void log_file_op(mlog_id_t type, ulint space_id, ulint first_page_no,
const char *path,
const char *new_path= nullptr, ulint flags= 0);
private:
/**
Write a complex page operation.
@param id page identifier
@param type type of operation */
void log_page_write(const page_id_t id, mlog_id_t type)
{
ut_ad(type == MLOG_INIT_FREE_PAGE || type == MLOG_COMP_PAGE_CREATE ||
type == MLOG_PAGE_CREATE);
if (m_log_mode == MTR_LOG_ALL)
m_log.close(log_write_low(type, id, m_log.open(11)));
}
/**
Write a log record.
@param type redo log record type
@param id persistent page identifier
@param l current end of mini-transaction log
@return new end of mini-transaction log */
inline byte *log_write_low(mlog_id_t type, const page_id_t id, byte *l)
{
ut_ad(type <= MLOG_BIGGEST_TYPE);
ut_ad(type == MLOG_FILE_NAME || type == MLOG_FILE_DELETE ||
type == MLOG_FILE_CREATE2 || type == MLOG_FILE_RENAME2 ||
is_named_space(id.space()));
*l++= type;
l+= mach_write_compressed(l, id.space());
l+= mach_write_compressed(l, id.page_no());
++m_n_log_recs;
return l;
}
/**
Write a log record for writing 1, 2, 4, or 8 bytes.
@param[in] type number of bytes to write
@param[in] block file page
@param[in] ptr pointer within block.frame
@param[in,out] l log record buffer
@return new end of mini-transaction log */
byte *log_write_low(mlog_id_t type, const buf_block_t &block,
const byte *ptr, byte *l);
/**
Write a log record for writing 1, 2, or 4 bytes.
@param[in] block file page
......
......@@ -40,6 +40,7 @@ Created 9/20/1997 Heikki Tuuri
#include "log0crypt.h"
#include "mem0mem.h"
#include "buf0buf.h"
#include "buf0dblwr.h"
#include "buf0flu.h"
#include "mtr0mtr.h"
#include "mtr0log.h"
......
......@@ -33,24 +33,7 @@ Created 12/7/1995 Heikki Tuuri
#include "dict0boot.h"
/********************************************************//**
Catenates n bytes to the mtr log. */
void
mlog_catenate_string(
/*=================*/
mtr_t* mtr, /*!< in: mtr */
const byte* str, /*!< in: string to write */
ulint len) /*!< in: string length */
{
if (mtr_get_log_mode(mtr) == MTR_LOG_NONE) {
return;
}
mtr->get_log()->push(str, ib_uint32_t(len));
}
/********************************************************//**
Parses an initial log record written by mlog_write_initial_log_record_low().
Parses an initial log record written by mtr_t::write_low().
@return parsed record end, NULL if not a complete record */
const byte*
mlog_parse_initial_log_record(
......@@ -215,24 +198,23 @@ mlog_parse_nbytes(
/**
Write a log record for writing 1, 2, 4, or 8 bytes.
@param[in] type number of bytes to write
@param[in] block file page
@param[in,out] ptr pointer in file page
@param[in] l number of bytes to write
@param[in,out] log_ptr log record buffer
@param[in,out] mtr mini-transaction */
static byte *
mlog_log_write_low(const buf_block_t &block, byte *ptr, mlog_id_t l,
byte *log_ptr, mtr_t &mtr)
@param[in] ptr pointer within block.frame
@param[in,out] l log record buffer
@return new end of mini-transaction log */
byte *mtr_t::log_write_low(mlog_id_t type, const buf_block_t &block,
const byte *ptr, byte *l)
{
ut_ad(type == MLOG_1BYTE || type == MLOG_2BYTES || type == MLOG_4BYTES ||
type == MLOG_8BYTES);
ut_ad(block.page.state == BUF_BLOCK_FILE_PAGE);
ut_ad(ptr >= block.frame + FIL_PAGE_OFFSET);
ut_ad(ptr + unsigned(l) <= &block.frame[srv_page_size - FIL_PAGE_DATA_END]);
log_ptr= mlog_write_initial_log_record_low(l,
block.page.id.space(),
block.page.id.page_no(),
log_ptr, &mtr);
mach_write_to_2(log_ptr, page_offset(ptr));
return log_ptr + 2;
ut_ad(ptr + unsigned(type) <=
&block.frame[srv_page_size - FIL_PAGE_DATA_END]);
l= log_write_low(type, block.page.id, l);
mach_write_to_2(l, page_offset(ptr));
return l + 2;
}
/**
......@@ -246,9 +228,9 @@ void mtr_t::log_write(const buf_block_t &block, byte *ptr, mlog_id_t l,
byte *log_ptr, uint32_t val)
{
ut_ad(l == MLOG_1BYTE || l == MLOG_2BYTES || l == MLOG_4BYTES);
log_ptr= mlog_log_write_low(block, ptr, l, log_ptr, *this);
log_ptr= log_write_low(l, block, ptr, log_ptr);
log_ptr+= mach_write_compressed(log_ptr, val);
mlog_close(this, log_ptr);
m_log.close(log_ptr);
}
/**
......@@ -262,9 +244,9 @@ void mtr_t::log_write(const buf_block_t &block, byte *ptr, mlog_id_t l,
byte *log_ptr, uint64_t val)
{
ut_ad(l == MLOG_8BYTES);
log_ptr= mlog_log_write_low(block, ptr, l, log_ptr, *this);
log_ptr= log_write_low(l, block, ptr, log_ptr);
log_ptr+= mach_u64_write_compressed(log_ptr, val);
mlog_close(this, log_ptr);
m_log.close(log_ptr);
}
/** Log a write of a byte string to a page.
......@@ -278,23 +260,20 @@ void mtr_t::memcpy(const buf_block_t &b, ulint ofs, ulint len)
ut_ad(ofs + len <= ulint(srv_page_size));
set_modified();
if (get_log_mode() != MTR_LOG_ALL)
if (m_log_mode != MTR_LOG_ALL)
{
ut_ad(get_log_mode() == MTR_LOG_NONE ||
get_log_mode() == MTR_LOG_NO_REDO);
ut_ad(m_log_mode == MTR_LOG_NONE || m_log_mode == MTR_LOG_NO_REDO);
return;
}
ut_ad(ofs + len < PAGE_DATA || !b.page.zip.data ||
mach_read_from_2(b.frame + FIL_PAGE_TYPE) <= FIL_PAGE_TYPE_ZBLOB2);
byte *l= get_log()->open(11 + 2 + 2);
l= mlog_write_initial_log_record_low(MLOG_WRITE_STRING, b.page.id.space(),
b.page.id.page_no(), l, this);
byte *l= log_write_low(MLOG_WRITE_STRING, b.page.id, m_log.open(11 + 2 + 2));
mach_write_to_2(l, ofs);
mach_write_to_2(l + 2, len);
mlog_close(this, l + 4);
mlog_catenate_string(this, b.frame + ofs, len);
m_log.close(l + 4);
m_log.push(b.frame + ofs, static_cast<uint32_t>(len));
}
/** Write a byte string to a ROW_FORMAT=COMPRESSED page.
......@@ -310,20 +289,17 @@ void mtr_t::zmemcpy(const buf_page_t &b, ulint offset, ulint len)
mach_read_from_2(b.zip.data + FIL_PAGE_TYPE) == FIL_PAGE_RTREE);
set_modified();
if (get_log_mode() != MTR_LOG_ALL)
if (m_log_mode != MTR_LOG_ALL)
{
ut_ad(get_log_mode() == MTR_LOG_NONE ||
get_log_mode() == MTR_LOG_NO_REDO);
ut_ad(m_log_mode == MTR_LOG_NONE || m_log_mode == MTR_LOG_NO_REDO);
return;
}
byte *l= get_log()->open(11 + 2 + 2);
l= mlog_write_initial_log_record_low(MLOG_ZIP_WRITE_STRING, b.id.space(),
b.id.page_no(), l, this);
byte *l= log_write_low(MLOG_ZIP_WRITE_STRING, b.id, m_log.open(11 + 2 + 2));
mach_write_to_2(l, offset);
mach_write_to_2(l + 2, len);
mlog_close(this, l + 4);
mlog_catenate_string(this, b.zip.data + offset, len);
m_log.close(l + 4);
m_log.push(b.zip.data + offset, static_cast<uint32_t>(len));
}
/********************************************************//**
......@@ -392,20 +368,17 @@ void mtr_t::memset(const buf_block_t* b, ulint ofs, ulint len, byte val)
::memset(ofs + b->frame, val, len);
set_modified();
if (get_log_mode() != MTR_LOG_ALL)
if (m_log_mode != MTR_LOG_ALL)
{
ut_ad(get_log_mode() == MTR_LOG_NONE ||
get_log_mode() == MTR_LOG_NO_REDO);
ut_ad(m_log_mode == MTR_LOG_NONE || m_log_mode == MTR_LOG_NO_REDO);
return;
}
byte *l= get_log()->open(11 + 2 + 2 + 1);
l= mlog_write_initial_log_record_low(MLOG_MEMSET, b->page.id.space(),
b->page.id.page_no(), l, this);
byte *l= log_write_low(MLOG_MEMSET, b->page.id, m_log.open(11 + 2 + 2 + 1));
mach_write_to_2(l, ofs);
mach_write_to_2(l + 2, len);
l[4]= val;
mlog_close(this, l + 5);
m_log.close(l + 5);
}
/********************************************************//**
......
......@@ -454,7 +454,7 @@ void mtr_t::commit_files(lsn_t checkpoint_lsn)
ut_ad(log_mutex_own());
ut_ad(is_active());
ut_ad(!is_inside_ibuf());
ut_ad(get_log_mode() == MTR_LOG_ALL);
ut_ad(m_log_mode == MTR_LOG_ALL);
ut_ad(!m_made_dirty);
ut_ad(m_memo.size() == 0);
ut_ad(!srv_read_only_mode);
......@@ -467,7 +467,7 @@ void mtr_t::commit_files(lsn_t checkpoint_lsn)
*m_log.front()->begin() |= MLOG_SINGLE_REC_FLAG;
break;
default:
mlog_catenate_ulint(&m_log, MLOG_MULTI_REC_END, MLOG_1BYTE);
*m_log.push<byte*>(1) = MLOG_MULTI_REC_END;
}
if (checkpoint_lsn) {
......@@ -497,7 +497,7 @@ mtr_t::is_named_space(ulint space) const
{
ut_ad(!m_user_space || m_user_space->id != TRX_SYS_SPACE);
switch (get_log_mode()) {
switch (m_log_mode) {
case MTR_LOG_NONE:
case MTR_LOG_NO_REDO:
return(true);
......@@ -517,7 +517,7 @@ bool mtr_t::is_named_space(const fil_space_t* space) const
{
ut_ad(!m_user_space || m_user_space->id != TRX_SYS_SPACE);
switch (get_log_mode()) {
switch (m_log_mode) {
case MTR_LOG_NONE:
case MTR_LOG_NO_REDO:
return true;
......@@ -548,7 +548,7 @@ mtr_t::x_lock_space(ulint space_id, const char* file, unsigned line)
} else if ((space = m_user_space) && space_id == space->id) {
} else {
space = fil_space_get(space_id);
ut_ad(get_log_mode() != MTR_LOG_NO_REDO
ut_ad(m_log_mode != MTR_LOG_NO_REDO
|| space->purpose == FIL_TYPE_TEMPORARY
|| space->purpose == FIL_TYPE_IMPORT);
}
......@@ -642,7 +642,7 @@ inline ulint mtr_t::prepare_write()
this tablespace since the latest checkpoint, so
some MLOG_FILE_NAME records were appended to m_log. */
ut_ad(m_n_log_recs > n_recs);
mlog_catenate_ulint(&m_log, MLOG_MULTI_REC_END, MLOG_1BYTE);
*m_log.push<byte*>(1) = MLOG_MULTI_REC_END;
len = m_log.size();
} else {
/* This was not the first time of dirtying a
......@@ -660,9 +660,7 @@ inline ulint mtr_t::prepare_write()
/* Because this mini-transaction comprises
multiple log records, append MLOG_MULTI_REC_END
at the end. */
mlog_catenate_ulint(&m_log, MLOG_MULTI_REC_END,
MLOG_1BYTE);
*m_log.push<byte*>(1) = MLOG_MULTI_REC_END;
len++;
}
}
......
......@@ -329,20 +329,7 @@ void page_create_low(const buf_block_t* block, bool comp)
@param[in] comp set unless ROW_FORMAT=REDUNDANT */
void page_create(buf_block_t* block, mtr_t* mtr, bool comp)
{
ut_ad(mtr->is_named_space(block->page.id.space()));
mtr->set_modified();
if (mtr->get_log_mode() != MTR_LOG_ALL) {
ut_ad(mtr->get_log_mode() == MTR_LOG_NONE
|| mtr->get_log_mode() == MTR_LOG_NO_REDO);
} else {
mlog_id_t type = comp
? MLOG_COMP_PAGE_CREATE : MLOG_PAGE_CREATE;
byte *l= mtr->get_log()->open(11);
l = mlog_write_initial_log_record_low(
type, block->page.id.space(), block->page.id.page_no(),
l, mtr);
mlog_close(mtr, l);
}
mtr->page_create(block->page.id, comp);
buf_block_modify_clock_inc(block);
page_create_low(block, comp);
}
......
......@@ -370,10 +370,12 @@ static void page_zip_compress_write_log(buf_block_t *block,
{
ut_ad(!index->is_ibuf());
byte *log_ptr= mlog_open(mtr, 11);
if (!log_ptr)
if (mtr->get_log_mode() != MTR_LOG_ALL)
{
ut_ad(mtr->get_log_mode() == MTR_LOG_NONE ||
mtr->get_log_mode() == MTR_LOG_NO_REDO);
return;
}
const page_t *page= block->frame;
const page_zip_des_t *page_zip= &block->page.zip;
......@@ -394,17 +396,13 @@ static void page_zip_compress_write_log(buf_block_t *block,
compile_time_assert(FIL_PAGE_DATA <= PAGE_DATA);
ut_a(page_zip->m_end + trailer_size <= page_zip_get_size(page_zip));
log_ptr= mlog_write_initial_log_record_low(MLOG_INIT_FILE_PAGE2,
block->page.id.space(),
block->page.id.page_no(),
log_ptr, mtr);
mlog_close(mtr, log_ptr);
mtr->init(block);
mtr->zmemcpy(block->page, FIL_PAGE_PREV, page_zip->m_end - FIL_PAGE_PREV);
if (trailer_size)
mtr->zmemcpy(block->page, page_zip_get_size(page_zip) - trailer_size,
trailer_size);
block->page.init_on_flush= true; /* because of MLOG_INIT_FILE_PAGE2 */
block->page.init_on_flush= true; /* because of mtr_t::init() */
}
/******************************************************//**
......
......@@ -52,6 +52,7 @@ Created 2/16/1996 Heikki Tuuri
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "buf0dblwr.h"
#include "buf0dump.h"
#include "os0file.h"
#include "os0thread.h"
......
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