MySQL  8.0.21
Source Code Documentation
mtr0log.h File Reference

Mini-transaction logging routines. More...

#include "dyn0buf.h"
#include "mtr0mtr.h"
#include "univ.i"
#include "mtr0log.ic"

Go to the source code of this file.

Macros

#define MLOG_BUF_MARGIN   256
 Insert, update, and maybe other functions may use this value to define an extra mlog buffer size for variable size data. More...
 

Functions

void mlog_write_ulint (byte *ptr, ulint val, mlog_id_t type, mtr_t *mtr)
 Writes 1, 2 or 4 bytes to a file page. More...
 
void mlog_write_ull (byte *ptr, ib_uint64_t val, mtr_t *mtr)
 Writes 8 bytes to a file page. More...
 
void mlog_write_string (byte *ptr, const byte *str, ulint len, mtr_t *mtr)
 Writes a string to a file page buffered in the buffer pool. More...
 
void mlog_log_string (byte *ptr, ulint len, mtr_t *mtr)
 Logs a write of a string to a file page buffered in the buffer pool. More...
 
void mlog_write_initial_log_record (const byte *ptr, mlog_id_t type, mtr_t *mtr)
 Writes initial part of a log record consisting of one-byte item type and four-byte space and page numbers. More...
 
UNIV_INLINE void mlog_catenate_ulint (mtr_buf_t *dyn_buf, ulint val, mlog_id_t type)
 Catenates 1 - 4 bytes to the mtr log. More...
 
UNIV_INLINE void mlog_catenate_ulint (mtr_t *mtr, ulint val, mlog_id_t type)
 Catenates 1 - 4 bytes to the mtr log. More...
 
void mlog_catenate_string (mtr_t *mtr, const byte *str, ulint len)
 Catenates n bytes to the mtr log. More...
 
UNIV_INLINE void mlog_catenate_ulint_compressed (mtr_t *mtr, ulint val)
 Catenates a compressed ulint to mlog. More...
 
UNIV_INLINE void mlog_catenate_ull_compressed (mtr_t *mtr, ib_uint64_t val)
 Catenates a compressed 64-bit integer to mlog. More...
 
UNIV_INLINE bool mlog_open (mtr_t *mtr, ulint size, byte *&buffer)
 Opens a buffer to mlog. More...
 
UNIV_INLINE bool mlog_open_metadata (mtr_t *mtr, ulint size, byte *&buffer)
 Opens a buffer to mlog. More...
 
UNIV_INLINE void mlog_close (mtr_t *mtr, byte *ptr)
 Closes a buffer opened to mlog. More...
 
UNIV_INLINE bytemlog_write_initial_dict_log_record (mlog_id_t type, table_id_t id, uint64_t version, byte *log_ptr, mtr_t *mtr)
 Writes a log record about a dictionary operation, which would cost at most 23 bytes. More...
 
UNIV_INLINE bytemlog_write_initial_log_record_low (mlog_id_t type, space_id_t space_id, page_no_t page_no, byte *log_ptr, mtr_t *mtr)
 Writes a log record about an operation. More...
 
UNIV_INLINE bytemlog_write_initial_log_record_fast (const byte *ptr, mlog_id_t type, byte *log_ptr, mtr_t *mtr)
 Writes the initial part of a log record (3..11 bytes). More...
 
bytemlog_parse_initial_dict_log_record (const byte *ptr, const byte *end_ptr, mlog_id_t *type, table_id_t *id, uint64 *version)
 Parses an initial log record written by mlog_write_initial_dict_log_record. More...
 
bytemlog_parse_initial_log_record (const byte *ptr, const byte *end_ptr, mlog_id_t *type, space_id_t *space, page_no_t *page_no)
 Parses an initial log record written by mlog_write_initial_log_record. More...
 
bytemlog_parse_nbytes (mlog_id_t type, const byte *ptr, const byte *end_ptr, byte *page, void *page_zip)
 Parses a log record written by mlog_write_ulint or mlog_write_ull. More...
 
bytemlog_parse_string (byte *ptr, byte *end_ptr, byte *page, void *page_zip)
 Parses a log record written by mlog_write_string. More...
 
bool mlog_open_and_write_index (mtr_t *mtr, const byte *rec, const dict_index_t *index, mlog_id_t type, ulint size, byte *&log_ptr)
 Opens a buffer for mlog, writes the initial log record and, if needed, the field lengths of an index. More...
 
bytemlog_parse_index (byte *ptr, const byte *end_ptr, ibool comp, dict_index_t **index)
 Parses a log record written by mlog_open_and_write_index. More...
 

Detailed Description

Mini-transaction logging routines.

Created 12/7/1995 Heikki Tuuri

Macro Definition Documentation

◆ MLOG_BUF_MARGIN

#define MLOG_BUF_MARGIN   256

Insert, update, and maybe other functions may use this value to define an extra mlog buffer size for variable size data.

Function Documentation

◆ mlog_catenate_string()

void mlog_catenate_string ( mtr_t mtr,
const byte str,
ulint  len 
)

Catenates n bytes to the mtr log.

in: string length

Parameters
mtrin: mtr
strin: string to write
lenin: string length

◆ mlog_catenate_ulint() [1/2]

UNIV_INLINE void mlog_catenate_ulint ( mtr_buf_t dyn_buf,
ulint  val,
mlog_id_t  type 
)

Catenates 1 - 4 bytes to the mtr log.

The value is not compressed.

Parameters
[in,out]dyn_bufbuffer to write
[in]valvalue to write
[in]typetype of value to write

◆ mlog_catenate_ulint() [2/2]

UNIV_INLINE void mlog_catenate_ulint ( mtr_t mtr,
ulint  val,
mlog_id_t  type 
)

Catenates 1 - 4 bytes to the mtr log.

Parameters
[in]mtrmtr
[in]valvalue to write
[in]typeMLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES

◆ mlog_catenate_ulint_compressed()

UNIV_INLINE void mlog_catenate_ulint_compressed ( mtr_t mtr,
ulint  val 
)

Catenates a compressed ulint to mlog.

Parameters
[in]mtrmtr
[in]valvalue to write

◆ mlog_catenate_ull_compressed()

UNIV_INLINE void mlog_catenate_ull_compressed ( mtr_t mtr,
ib_uint64_t  val 
)

Catenates a compressed 64-bit integer to mlog.

Parameters
[in]mtrmtr
[in]valvalue to write

◆ mlog_close()

UNIV_INLINE void mlog_close ( mtr_t mtr,
byte ptr 
)

Closes a buffer opened to mlog.

Parameters
[in]mtrmtr
[in]ptrbuffer space from ptr up was not used

◆ mlog_log_string()

void mlog_log_string ( byte ptr,
ulint  len,
mtr_t mtr 
)

Logs a write of a string to a file page buffered in the buffer pool.

Writes the corresponding log record to the mini-transaction log. in: mini-transaction handle

Writes the corresponding log record to the mini-transaction log.

Parameters
ptrin: pointer written to
lenin: string length
mtrin: mini-transaction handle

◆ mlog_open()

UNIV_INLINE bool mlog_open ( mtr_t mtr,
ulint  size,
byte *&  buffer 
)

Opens a buffer to mlog.

It must be closed with mlog_close.

Parameters
[in,out]mtrmtr
[in]sizebuffer size in bytes; MUST be smaller than DYN_ARRAY_DATA_SIZE!
[out]buffermlog buffer pointer if opened successfully
Return values
trueif opened successfully.
falseif not opened. One case is when redo is disabled for mtr.

◆ mlog_open_and_write_index()

bool mlog_open_and_write_index ( mtr_t mtr,
const byte rec,
const dict_index_t index,
mlog_id_t  type,
ulint  size,
byte *&  log_ptr 
)

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().

Parameters
[in,out]mtrmini transaction
[in]recindex record or page
[in]indexrecord descriptor
[in]typelog item type
[in]sizerequested buffer size in bytes. if 0, calls mlog_close() and returns false.
[out]log_ptrlog buffer pointer
Return values
trueif opened successfully.
falseif not opened. One case is when redo is disabled for mtr.

◆ mlog_open_metadata()

UNIV_INLINE bool mlog_open_metadata ( mtr_t mtr,
ulint  size,
byte *&  buffer 
)

Opens a buffer to mlog.

It must be closed with mlog_close. This is used for writing log for metadata changes

Parameters
[in,out]mtrmtr
[in]sizebuffer size in bytes; MUST be smaller than DYN_ARRAY_DATA_SIZE!
[out]buffermlog buffer pointer if opened successfully
Return values
trueif opened successfully.
falseif not opened. One case is when redo is disabled for mtr.

◆ mlog_parse_index()

byte* mlog_parse_index ( byte ptr,
const byte end_ptr,
ibool  comp,
dict_index_t **  index 
)

Parses a log record written by mlog_open_and_write_index.

Returns
parsed record end, NULL if not a complete record out, own: dummy index
parsed record end, NULL if not a complete record
Parameters
ptrin: buffer
end_ptrin: buffer end
compin: TRUE=compact row format
indexout, own: dummy index

◆ mlog_parse_initial_dict_log_record()

byte* mlog_parse_initial_dict_log_record ( const byte ptr,
const byte end_ptr,
mlog_id_t type,
table_id_t id,
uint64 version 
)

Parses an initial log record written by mlog_write_initial_dict_log_record.

Parameters
[in]ptrbuffer
[in]end_ptrbuffer end
[out]typelog record type, should be MLOG_TABLE_DYNAMIC_META
[out]idtable id
[out]versiontable dynamic metadata version
Returns
parsed record end, NULL if not a complete record

Parses an initial log record written by mlog_write_initial_dict_log_record.

Parameters
[in]ptrbuffer
[in]end_ptrbuffer end
[out]typelog record type, should be MLOG_TABLE_DYNAMIC_META
[out]idtable id
[out]versiontable dynamic metadata version
Returns
parsed record end, NULL if not a complete record

◆ mlog_parse_initial_log_record()

byte* mlog_parse_initial_log_record ( const byte ptr,
const byte end_ptr,
mlog_id_t type,
space_id_t space,
page_no_t page_no 
)

Parses an initial log record written by mlog_write_initial_log_record.

Returns
parsed record end, NULL if not a complete record out: page number
parsed record end, NULL if not a complete record
Parameters
ptrin: buffer
end_ptrin: buffer end
typeout: log record type: MLOG_1BYTE, ...
spaceout: space id
page_noout: page number

◆ mlog_parse_nbytes()

byte* mlog_parse_nbytes ( mlog_id_t  type,
const byte ptr,
const byte end_ptr,
byte page,
void *  page_zip 
)

Parses a log record written by mlog_write_ulint or mlog_write_ull.

Returns
parsed record end, NULL if not a complete record in/out: compressed page, or NULL
parsed record end, NULL if not a complete record or a corrupt record
Parameters
typein: log record type: MLOG_1BYTE, ...
ptrin: buffer
end_ptrin: buffer end
pagein: page where to apply the log record, or NULL
page_zipin/out: compressed page, or NULL

◆ mlog_parse_string()

byte* mlog_parse_string ( byte ptr,
byte end_ptr,
byte page,
void *  page_zip 
)

Parses a log record written by mlog_write_string.

Returns
parsed record end, NULL if not a complete record in/out: compressed page, or NULL
parsed record end, NULL if not a complete record
Parameters
ptrin: buffer
end_ptrin: buffer end
pagein: page where to apply the log record, or NULL
page_zipin/out: compressed page, or NULL

◆ mlog_write_initial_dict_log_record()

UNIV_INLINE byte* mlog_write_initial_dict_log_record ( mlog_id_t  type,
table_id_t  id,
uint64_t  version,
byte log_ptr,
mtr_t mtr 
)

Writes a log record about a dictionary operation, which would cost at most 23 bytes.

Parameters
[in]typeredo log record type
[in]idtable id
[in]versiontable dynamic metadata version
[in,out]log_ptrcurrent end of mini-transaction log
[in,out]mtrmini-transaction
Returns
end of mini-transaction log

◆ mlog_write_initial_log_record()

void mlog_write_initial_log_record ( const byte ptr,
mlog_id_t  type,
mtr_t mtr 
)

Writes initial part of a log record consisting of one-byte item type and four-byte space and page numbers.

in: mini-transaction handle

Writes initial part of a log record consisting of one-byte item type and four-byte space and page numbers.

Also pushes info to the mtr memo that a buffer page has been modified.

Parameters
ptrin: pointer to (inside) a buffer frame holding the file page where modification is made
typein: log item type: MLOG_1BYTE, ...
mtrin: mini-transaction handle

◆ mlog_write_initial_log_record_fast()

UNIV_INLINE byte* mlog_write_initial_log_record_fast ( const byte ptr,
mlog_id_t  type,
byte log_ptr,
mtr_t mtr 
)

Writes the initial part of a log record (3..11 bytes).

If the implementation of this function is changed, all size parameters to mlog_open() should be adjusted accordingly!

Parameters
[in]ptrpointer to (inside) a buffer frame holding the file page where modification is made
[in]typelog item type: MLOG_1BYTE, ...
[in]log_ptrpointer to mtr log which has been opened
[in]mtrmtr
Returns
new value of log_ptr

◆ mlog_write_initial_log_record_low()

UNIV_INLINE byte* mlog_write_initial_log_record_low ( mlog_id_t  type,
space_id_t  space_id,
page_no_t  page_no,
byte log_ptr,
mtr_t mtr 
)

Writes a log record about an operation.

Parameters
[in]typeredo log record type
[in]space_idtablespace identifier
[in]page_nopage number
[in,out]log_ptrcurrent end of mini-transaction log
[in,out]mtrmini-transaction
Returns
end of mini-transaction log

◆ mlog_write_string()

void mlog_write_string ( byte ptr,
const byte str,
ulint  len,
mtr_t mtr 
)

Writes a string to a file page buffered in the buffer pool.

Writes the corresponding log record to the mini-transaction log. in: mini-transaction handle

Writes the corresponding log record to the mini-transaction log.

Parameters
ptrin: pointer where to write
strin: string to write
lenin: string length
mtrin: mini-transaction handle

◆ mlog_write_ulint()

void mlog_write_ulint ( byte ptr,
ulint  val,
mlog_id_t  type,
mtr_t mtr 
)

Writes 1, 2 or 4 bytes to a file page.

Writes the corresponding log record to the mini-transaction log if mtr is not NULL. in: mini-transaction handle

Writes the corresponding log record to the mini-transaction log if mtr is not NULL.

Parameters
ptrin: pointer where to write
valin: value to write
typein: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES
mtrin: mini-transaction handle

◆ mlog_write_ull()

void mlog_write_ull ( byte ptr,
ib_uint64_t  val,
mtr_t mtr 
)

Writes 8 bytes to a file page.

Writes the corresponding log record to the mini-transaction log, only if mtr is not NULL in: mini-transaction handle

Writes the corresponding log record to the mini-transaction log, only if mtr is not NULL

Parameters
ptrin: pointer where to write
valin: value to write
mtrin: mini-transaction handle