MySQL 8.0.39
Source Code Documentation
|
Mini-transaction log routines. More...
#include "mtr0log.h"
#include "buf0buf.h"
#include "buf0dblwr.h"
#include "dict0dict.h"
#include "log0recv.h"
#include "page0page.h"
#include "dict0boot.h"
Classes | |
struct | Field_instant_info |
Typedefs | |
using | instant_fields_list_t = std::vector< Field_instant_info > |
Functions | |
static byte * | mlog_parse_index_v1 (byte *ptr, const byte *end_ptr, dict_index_t **index) |
Parses a log record written by mlog_open_and_write_index. More... | |
void | mlog_catenate_string (mtr_t *mtr, const byte *str, ulint len) |
Catenates n bytes to the mtr log. More... | |
void | mlog_write_initial_log_record (const byte *ptr, mlog_id_t type, mtr_t *mtr) |
Writes the initial part of a log record consisting of one-byte item type and four-byte space and page numbers. More... | |
byte * | mlog_parse_initial_dict_log_record (const byte *ptr, const byte *end_ptr, mlog_id_t *type, table_id_t *id, uint64_t *version) |
Parses an initial log record written by mlog_write_initial_dict_log_record. More... | |
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. More... | |
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. More... | |
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, 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... | |
byte * | mlog_parse_string (byte *ptr, byte *end_ptr, byte *page, void *page_zip) |
Parses a log record written by mlog_write_string. More... | |
byte * | mlog_parse_index_8027 (byte *ptr, const byte *end_ptr, bool comp, dict_index_t **index) |
Parses a log record written by mlog_open_and_write_index in version <= 8027. More... | |
static void | log_index_get_size_needed (const dict_index_t *index, size_t size, uint16_t n, bool is_comp, bool is_versioned, bool is_instant, const bool *fields_with_changed_order, size_t &size_needed) |
Calculate total size needed to log index information. More... | |
static void | log_index_log_version (uint8_t version, byte *&log_ptr) |
Log the index log version. More... | |
static void | log_index_flag (uint8_t flag, byte *&log_ptr) |
Log the flag. More... | |
static void | log_index_column_counts (const dict_index_t *index, uint16_t n, const byte *rec, bool is_comp, bool is_versioned, bool is_instant, byte *&log_ptr) |
Log the number of fields in index. More... | |
static bool | close_and_reopen_log (byte *&log_ptr, const byte *&log_start, const byte *&log_end, mtr_t *&mtr, size_t &alloc, size_t &total) |
Close, allocate and reopen LOG pointer buffer. More... | |
template<typename F > | |
static bool | log_index_fields (const dict_index_t *index, uint16_t n, bool is_versioned, std::vector< dict_field_t * > &f, bool *changed_order, byte *&log_ptr, F &func) |
Log index field len info. More... | |
template<typename F > | |
static bool | log_index_versioned_fields (const std::vector< dict_field_t * > &f, byte *&log_ptr, F &func, const dict_index_t *index) |
Log fields with version. More... | |
bool | mlog_open_and_write_index (mtr_t *mtr, const byte *rec, const dict_index_t *index, mlog_id_t type, size_t size, byte *&log_ptr) |
Opens a buffer for mlog, writes the initial log record and, if needed, the field lengths of an index. More... | |
static byte * | read_2_bytes (byte *ptr, const byte *end_ptr, uint16_t &val) |
Read 2 bytes from log buffer. More... | |
static byte * | read_1_bytes (byte *ptr, const byte *end_ptr, uint8_t &val) |
Read 1 bytes from log buffer. More... | |
static byte * | parse_index_column_counts (byte *ptr, const byte *end_ptr, bool is_comp, bool is_versioned, bool is_instant, uint16_t &n, uint16_t &n_uniq, uint16_t &inst_cols) |
Read number of columns for index. More... | |
static byte * | parse_index_fields (byte *ptr, const byte *end_ptr, uint16_t n, uint16_t n_uniq, bool is_versioned, dict_index_t *&ind, dict_table_t *&table) |
Parse index fields. More... | |
static byte * | parse_index_versioned_fields (byte *ptr, const byte *end_ptr, instant_fields_list_t &f, uint16_t &crv, size_t &n_dropped) |
Parse the fields with versions. More... | |
static void | update_instant_info (instant_fields_list_t f, dict_index_t *index) |
Update the version info for the columns. More... | |
static void | populate_dummy_fields (dict_index_t *index, dict_table_t *table, size_t n, bool is_comp) |
To populate dummy fields. More... | |
static byte * | parse_index_log_version (byte *ptr, const byte *end_ptr, uint8_t &version) |
static byte * | parse_index_flag (byte *ptr, const byte *end_ptr, uint8_t &flag) |
byte * | mlog_parse_index (byte *ptr, const byte *end_ptr, dict_index_t **index) |
Parses a log record written by mlog_open_and_write_index. More... | |
Variables | |
constexpr size_t | inst_col_info_size = 6 |
Mini-transaction log routines.
Created 12/7/1995 Heikki Tuuri
using instant_fields_list_t = std::vector<Field_instant_info> |
|
static |
Close, allocate and reopen LOG pointer buffer.
[in] | log_ptr | pointer to log buffer |
[in,out] | log_start | start of currently allocated buffer |
[in,out] | log_end | end of currently allocated buffer |
[in] | mtr | mini transaction |
[in,out] | alloc | size allocated as of now on log |
[in,out] | total | total size needed on log |
|
static |
Log the number of fields in index.
[in] | index | index |
[in] | n | number of fields |
[in] | rec | index record |
[in] | is_comp | true if COMP |
[in] | is_versioned | true if table has row versions |
[in] | is_instant | true if table has INSTANT cols |
[in,out] | log_ptr | REDO LOG buffer pointer |
|
static |
Log index field len info.
[in] | index | index |
[in] | n | number of fields |
[in] | is_versioned | true if table has row versions |
[in,out] | f | vector of fields with versions |
[in] | changed_order | array indicating fields changed position |
[in] | log_ptr | log buffer pointer |
[in] | func | callback to check size reopen log buffer |
|
static |
Log the flag.
[in] | flag | 1 byte flag to be logged |
[in,out] | log_ptr | REDO LOG buffer pointer |
|
static |
Calculate total size needed to log index information.
[in] | index | index |
[in] | size | size passed from caller |
[in] | n | number of fields in index |
[in] | is_comp | true if COMP |
[in] | is_versioned | if table has row versions |
[in] | is_instant | true if table has INSTANT cols |
[in] | fields_with_changed_order | bitmap to indicate fields with changed order |
[out] | size_needed | total size needed on REDO LOG |
|
static |
Log the index log version.
[in] | version | 1 byte index log version |
[in,out] | log_ptr | REDO LOG buffer pointer |
|
static |
Log fields with version.
[in] | f | vector of fields with versions |
[in] | log_ptr | log buffer pointer |
[in] | func | callback to check size reopen log buffer |
[in] | index | index to fetch field's logical position |
Catenates n bytes to the mtr log.
[in] | mtr | Mini-transaction |
[in] | str | String to write |
[in] | len | String length |
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.
ptr | in: pointer written to |
len | in: string length |
mtr | in: mini-transaction handle |
bool mlog_open_and_write_index | ( | mtr_t * | mtr, |
const byte * | rec, | ||
const dict_index_t * | index, | ||
mlog_id_t | type, | ||
size_t | 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().
[in,out] | mtr | Mini-transaction |
[in] | rec | Index record or page |
[in] | index | Record descriptor |
[in] | type | Log item type |
[in] | size | Requested buffer size in bytes. if 0, calls mlog_close() and returns false. |
[out] | log_ptr | Log buffer pointer |
true | if opened successfully. |
false | if not opened. One case is when redo is disabled for mtr. |
byte * mlog_parse_index | ( | byte * | ptr, |
const byte * | end_ptr, | ||
dict_index_t ** | index | ||
) |
Parses a log record written by mlog_open_and_write_index.
[in] | ptr | buffer |
[in] | end_ptr | buffer end |
[out] | index | own: dummy index |
byte * mlog_parse_index_8027 | ( | byte * | ptr, |
const byte * | end_ptr, | ||
bool | comp, | ||
dict_index_t ** | index | ||
) |
Parses a log record written by mlog_open_and_write_index in version <= 8027.
This function should never be changed and should be removed once recovery from mysql-8.0.27 is not needed anymore.
[in] | ptr | buffer |
[in] | end_ptr | buffer end |
[in] | comp | true=compact row format |
[out] | index | own: dummy index |
|
static |
Parses a log record written by mlog_open_and_write_index.
[in] | ptr | buffer |
[in] | end_ptr | buffer end |
[out] | index | own: dummy index |
byte * mlog_parse_initial_dict_log_record | ( | const byte * | ptr, |
const byte * | end_ptr, | ||
mlog_id_t * | type, | ||
table_id_t * | id, | ||
uint64_t * | version | ||
) |
Parses an initial log record written by mlog_write_initial_dict_log_record.
[in] | ptr | buffer |
[in] | end_ptr | buffer end |
[out] | type | log record type, should be MLOG_TABLE_DYNAMIC_META |
[out] | id | table id |
[out] | version | table dynamic metadata version |
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.
ptr | in: buffer |
end_ptr | in: buffer end |
type | out: log record type: MLOG_1BYTE, ... |
space | out: space id |
page_no | out: page number |
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.
type | in: log record type: MLOG_1BYTE, ... |
ptr | in: buffer |
end_ptr | in: buffer end |
page | in: page where to apply the log record, or NULL |
page_zip | in/out: compressed page, or NULL |
Parses a log record written by mlog_write_string.
ptr | in: buffer |
end_ptr | in: buffer end |
page | in: page where to apply the log record, or NULL |
page_zip | in/out: compressed page, or NULL |
Writes the initial part of a log record consisting of one-byte item type and four-byte space and page numbers.
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.
ptr | in: pointer to (inside) a buffer frame holding the file page where modification is made |
type | in: log item type: MLOG_1BYTE, ... |
mtr | in: mini-transaction handle |
Writes a string to a file page buffered in the buffer pool.
Writes the corresponding log record to the mini-transaction log.
ptr | in: pointer where to write |
str | in: string to write |
len | in: string length |
mtr | in: mini-transaction handle |
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.
ptr | in: pointer where to write |
val | in: value to write |
type | in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES |
mtr | in: mini-transaction handle |
Writes 8 bytes to a file page.
Writes the corresponding log record to the mini-transaction log, only if mtr is not NULL
ptr | in: pointer where to write |
val | in: value to write |
mtr | in: mini-transaction handle |
|
static |
Read number of columns for index.
[in] | ptr | pointer to buffer |
[in] | end_ptr | pointer to end of buffer |
[in] | is_comp | true if COMP |
[in] | is_versioned | true if table has row versions |
[in] | is_instant | true if table has INSTANT cols |
[out] | n | number of index fields |
[out] | n_uniq | n_uniq for index |
[out] | inst_cols | number of column before first instant add was done. |
|
static |
Parse index fields.
[in] | ptr | pointer to buffer |
[in] | end_ptr | pointer to end of buffer |
[in] | n | number of fields |
[in] | n_uniq | n_uniq |
[in] | is_versioned | true if table has row versions |
[in,out] | ind | dummy index |
[in,out] | table | dummy table |
|
static |
|
static |
Parse the fields with versions.
[in] | ptr | pointer to buffer |
[in] | end_ptr | pointer to end of buffer |
[out] | f | vector of fields with versions |
[out] | crv | current row version |
[out] | n_dropped | number of dropped columns |
|
static |
To populate dummy fields.
Used only in case of REDUNDANT row format.
[in,out] | index | dummy index |
[in,out] | table | dummy table |
[in] | n | number of fields |
[in] | is_comp | true if COMP |
Read 1 bytes from log buffer.
[in] | ptr | pointer to buffer |
[in] | end_ptr | pointer to end of buffer |
[out] | val | read 2 bytes value |
Read 2 bytes from log buffer.
[in] | ptr | pointer to buffer |
[in] | end_ptr | pointer to end of buffer |
[out] | val | read 2 bytes value |
|
static |
Update the version info for the columns.
NOTE : fields are logged in their physical order so with the help of phy_pos, it's easy to locate them.
[in] | f | fields with versions |
[in,out] | index | dummy index |
|
constexpr |