📄 log0log.h
字号:
ulintlog_archive_start(void);/*===================*/ /* out: DB_SUCCESS or DB_ERROR *//********************************************************************Stop archiving the log so that a gap may occur in the archived log files. */ulintlog_archive_noarchivelog(void);/*==========================*/ /* out: DB_SUCCESS or DB_ERROR *//********************************************************************Start archiving the log so that a gap may occur in the archived log files. */ulintlog_archive_archivelog(void);/*========================*/ /* out: DB_SUCCESS or DB_ERROR *//**********************************************************Generates an archived log file name. */voidlog_archived_file_name_gen(/*=======================*/ char* buf, /* in: buffer where to write */ ulint id, /* in: group id */ ulint file_no);/* in: file number *//************************************************************************Checks that there is enough free space in the log to start a new query step.Flushes the log buffer or makes a new checkpoint if necessary. NOTE: thisfunction may only be called if the calling thread owns no synchronizationobjects! */voidlog_check_margins(void);/*===================*//**********************************************************Reads a specified log segment to a buffer. */voidlog_group_read_log_seg(/*===================*/ ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */ byte* buf, /* in: buffer where to read */ log_group_t* group, /* in: log group */ dulint start_lsn, /* in: read area start */ dulint end_lsn); /* in: read area end *//**********************************************************Writes a buffer to a log file group. */voidlog_group_write_buf(/*================*/ log_group_t* group, /* in: log group */ byte* buf, /* in: buffer */ ulint len, /* in: buffer len; must be divisible by OS_FILE_LOG_BLOCK_SIZE */ dulint start_lsn, /* in: start lsn of the buffer; must be divisible by OS_FILE_LOG_BLOCK_SIZE */ ulint new_data_offset);/* in: start offset of new data in buf: this parameter is used to decide if we have to write a new log file header *//************************************************************Sets the field values in group to correspond to a given lsn. For this functionto work, the values must already be correctly initialized to correspond tosome lsn, for instance, a checkpoint lsn. */voidlog_group_set_fields(/*=================*/ log_group_t* group, /* in: group */ dulint lsn); /* in: lsn for which the values should be set *//**********************************************************Calculates the data capacity of a log group, when the log file headers are notincluded. */ulintlog_group_get_capacity(/*===================*/ /* out: capacity in bytes */ log_group_t* group); /* in: log group *//****************************************************************Gets a log block flush bit. */UNIV_INLINEiboollog_block_get_flush_bit(/*====================*/ /* out: TRUE if this block was the first to be written in a log flush */ byte* log_block); /* in: log block *//****************************************************************Gets a log block number stored in the header. */UNIV_INLINEulintlog_block_get_hdr_no(/*=================*/ /* out: log block number stored in the block header */ byte* log_block); /* in: log block *//****************************************************************Gets a log block data length. */UNIV_INLINEulintlog_block_get_data_len(/*===================*/ /* out: log block data length measured as a byte offset from the block start */ byte* log_block); /* in: log block *//****************************************************************Sets the log block data length. */UNIV_INLINEvoidlog_block_set_data_len(/*===================*/ byte* log_block, /* in: log block */ ulint len); /* in: data length *//****************************************************************Calculates the checksum for a log block. */UNIV_INLINEulintlog_block_calc_checksum(/*====================*/ /* out: checksum */ byte* block); /* in: log block *//****************************************************************Gets a log block checksum field value. */UNIV_INLINEulintlog_block_get_checksum(/*===================*/ /* out: checksum */ byte* log_block); /* in: log block *//****************************************************************Sets a log block checksum field value. */UNIV_INLINEvoidlog_block_set_checksum(/*===================*/ byte* log_block, /* in: log block */ ulint checksum); /* in: checksum *//****************************************************************Gets a log block first mtr log record group offset. */UNIV_INLINEulintlog_block_get_first_rec_group(/*==========================*/ /* out: first mtr log record group byte offset from the block start, 0 if none */ byte* log_block); /* in: log block *//****************************************************************Sets the log block first mtr log record group offset. */UNIV_INLINEvoidlog_block_set_first_rec_group(/*==========================*/ byte* log_block, /* in: log block */ ulint offset); /* in: offset, 0 if none *//****************************************************************Gets a log block checkpoint number field (4 lowest bytes). */UNIV_INLINEulintlog_block_get_checkpoint_no(/*========================*/ /* out: checkpoint no (4 lowest bytes) */ byte* log_block); /* in: log block *//****************************************************************Initializes a log block in the log buffer. */UNIV_INLINEvoidlog_block_init(/*===========*/ byte* log_block, /* in: pointer to the log buffer */ dulint lsn); /* in: lsn within the log block *//****************************************************************Initializes a log block in the log buffer in the old, < 3.23.52 format, wherethere was no checksum yet. */UNIV_INLINEvoidlog_block_init_in_old_format(/*=========================*/ byte* log_block, /* in: pointer to the log buffer */ dulint lsn); /* in: lsn within the log block *//****************************************************************Converts a lsn to a log block number. */UNIV_INLINEulintlog_block_convert_lsn_to_no(/*========================*/ /* out: log block number, it is > 0 and <= 1G */ dulint lsn); /* in: lsn of a byte within the block *//**********************************************************Prints info of the log. */voidlog_print(/*======*/ FILE* file); /* in: file where to print *//**********************************************************Peeks the current lsn. */iboollog_peek_lsn(/*=========*/ /* out: TRUE if success, FALSE if could not get the log system mutex */ dulint* lsn); /* out: if returns TRUE, current lsn is here *//**************************************************************************Refreshes the statistics used to print per-second averages. */voidlog_refresh_stats(void);/*===================*/extern log_t* log_sys;/* Values used as flags */#define LOG_FLUSH 7652559#define LOG_CHECKPOINT 78656949#define LOG_ARCHIVE 11122331#define LOG_RECOVER 98887331/* The counting of lsn's starts from this value: this must be non-zero */#define LOG_START_LSN ut_dulint_create(0, 16 * OS_FILE_LOG_BLOCK_SIZE)#define LOG_BUFFER_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE)#define LOG_ARCHIVE_BUF_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE / 4)/* Offsets of a log block header */#define LOG_BLOCK_HDR_NO 0 /* block number which must be > 0 and is allowed to wrap around at 2G; the highest bit is set to 1 if this is the first log block in a log flush write segment */#define LOG_BLOCK_FLUSH_BIT_MASK 0x80000000UL /* mask used to get the highest bit in the preceding field */#define LOG_BLOCK_HDR_DATA_LEN 4 /* number of bytes of log written to this block */#define LOG_BLOCK_FIRST_REC_GROUP 6 /* offset of the first start of an mtr log record group in this log block, 0 if none; if the value is the same as LOG_BLOCK_HDR_DATA_LEN, it means that the first rec group has not yet been catenated to this log block, but if it will, it will start at this offset; an archive recovery can start parsing the log records starting from this offset in this log block, if value not 0 */#define LOG_BLOCK_CHECKPOINT_NO 8 /* 4 lower bytes of the value of log_sys->next_checkpoint_no when the log block was last written to: if the block has not yet been written full, this value is only updated before a log buffer flush */#define LOG_BLOCK_HDR_SIZE 12 /* size of the log block header in bytes *//* Offsets of a log block trailer from the end of the block */#define LOG_BLOCK_CHECKSUM 4 /* 4 byte checksum of the log block contents; in InnoDB versions < 3.23.52 this did not contain the checksum but the same value as .._HDR_NO */#define LOG_BLOCK_TRL_SIZE 4 /* trailer size in bytes *//* Offsets for a checkpoint field */#define LOG_CHECKPOINT_NO 0#define LOG_CHECKPOINT_LSN 8#define LOG_CHECKPOINT_OFFSET 16#define LOG_CHECKPOINT_LOG_BUF_SIZE 20#define LOG_CHECKPOINT_ARCHIVED_LSN 24#define LOG_CHECKPOINT_GROUP_ARRAY 32/* For each value < LOG_MAX_N_GROUPS the following 8 bytes: */#define LOG_CHECKPOINT_ARCHIVED_FILE_NO 0#define LOG_CHECKPOINT_ARCHIVED_OFFSET 4#define LOG_CHECKPOINT_ARRAY_END (LOG_CHECKPOINT_GROUP_ARRAY\ + LOG_MAX_N_GROUPS * 8)#define LOG_CHECKPOINT_CHECKSUM_1 LOG_CHECKPOINT_ARRAY_END#define LOG_CHECKPOINT_CHECKSUM_2 (4 + LOG_CHECKPOINT_ARRAY_END)#define LOG_CHECKPOINT_FSP_FREE_LIMIT (8 + LOG_CHECKPOINT_ARRAY_END) /* current fsp free limit in tablespace 0, in units of one
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -