📄 log0log.h
字号:
/******************************************************Database log(c) 1995 Innobase OyCreated 12/9/1995 Heikki Tuuri*******************************************************/#ifndef log0log_h#define log0log_h#include "univ.i"#include "ut0byte.h"#include "sync0sync.h"#include "sync0rw.h"typedef struct log_struct log_t;typedef struct log_group_struct log_group_t;#ifdef UNIV_DEBUGextern ibool log_do_write;extern ibool log_debug_writes;#else /* UNIV_DEBUG */# define log_do_write TRUE#endif /* UNIV_DEBUG *//* Wait modes for log_write_up_to */#define LOG_NO_WAIT 91#define LOG_WAIT_ONE_GROUP 92#define LOG_WAIT_ALL_GROUPS 93#define LOG_MAX_N_GROUPS 32/********************************************************************Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,so that we know that the limit has been written to a log checkpoint fieldon disk. */voidlog_fsp_current_free_limit_set_and_checkpoint(/*==========================================*/ ulint limit); /* in: limit to set *//***********************************************************************Calculates where in log files we find a specified lsn. */ulintlog_calc_where_lsn_is(/*==================*/ /* out: log file number */ ib_longlong* log_file_offset, /* out: offset in that file (including the header) */ dulint first_header_lsn, /* in: first log file start lsn */ dulint lsn, /* in: lsn whose position to determine */ ulint n_log_files, /* in: total number of log files */ ib_longlong log_file_size); /* in: log file size (including the header) *//****************************************************************Writes to the log the string given. The log must be released withlog_release. */UNIV_INLINEdulintlog_reserve_and_write_fast(/*=======================*/ /* out: end lsn of the log record, ut_dulint_zero if did not succeed */ byte* str, /* in: string */ ulint len, /* in: string length */ dulint* start_lsn,/* out: start lsn of the log record */ ibool* success);/* out: TRUE if success *//***************************************************************************Releases the log mutex. */UNIV_INLINEvoidlog_release(void);/*=============*//***************************************************************************Checks if there is need for a log buffer flush or a new checkpoint, and doesthis if yes. Any database operation should call this when it has modifiedmore than about 4 pages. NOTE that this function may only be called when theOS thread owns no synchronization objects except the dictionary mutex. */UNIV_INLINEvoidlog_free_check(void);/*================*//****************************************************************Opens the log for log_write_low. The log must be closed with log_close andreleased with log_release. */dulintlog_reserve_and_open(/*=================*/ /* out: start lsn of the log record */ ulint len); /* in: length of data to be catenated *//****************************************************************Writes to the log the string given. It is assumed that the caller holds thelog mutex. */voidlog_write_low(/*==========*/ byte* str, /* in: string */ ulint str_len); /* in: string length *//****************************************************************Closes the log. */dulintlog_close(void);/*===========*/ /* out: lsn *//****************************************************************Gets the current lsn. */UNIV_INLINEdulintlog_get_lsn(void);/*=============*/ /* out: current lsn *//**********************************************************Initializes the log. */voidlog_init(void);/*==========*//**********************************************************************Inits a log group to the log system. */voidlog_group_init(/*===========*/ ulint id, /* in: group id */ ulint n_files, /* in: number of log files */ ulint file_size, /* in: log file size in bytes */ ulint space_id, /* in: space id of the file space which contains the log files of this group */ ulint archive_space_id); /* in: space id of the file space which contains some archived log files for this group; currently, only for the first log group this is used *//**********************************************************Completes an i/o to a log file. */voidlog_io_complete(/*============*/ log_group_t* group); /* in: log group *//**********************************************************This function is called, e.g., when a transaction wants to commit. It checksthat the log has been written to the log file up to the last log entry writtenby the transaction. If there is a flush running, it waits and checks if theflush flushed enough. If not, starts a new flush. */voidlog_write_up_to(/*============*/ dulint lsn, /* in: log sequence number up to which the log should be written, ut_dulint_max if not specified */ ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP, or LOG_WAIT_ALL_GROUPS */ ibool flush_to_disk); /* in: TRUE if we want the written log also to be flushed to disk *//********************************************************************Does a syncronous flush of the log buffer to disk. */voidlog_buffer_flush_to_disk(void);/*==========================*//********************************************************************Advances the smallest lsn for which there are unflushed dirty blocks in thebuffer pool and also may make a new checkpoint. NOTE: this function may onlybe called if the calling thread owns no synchronization objects! */iboollog_preflush_pool_modified_pages(/*=============================*/ /* out: FALSE if there was a flush batch of the same type running, which means that we could not start this flush batch */ dulint new_oldest, /* in: try to advance oldest_modified_lsn at least to this lsn */ ibool sync); /* in: TRUE if synchronous operation is desired *//**********************************************************Makes a checkpoint. Note that this function does not flush dirtyblocks from the buffer pool: it only checks what is lsn of the oldestmodification in the pool, and writes information about the lsn inlog files. Use log_make_checkpoint_at to flush also the pool. */iboollog_checkpoint(/*===========*/ /* out: TRUE if success, FALSE if a checkpoint write was already running */ ibool sync, /* in: TRUE if synchronous operation is desired */ ibool write_always); /* in: the function normally checks if the the new checkpoint would have a greater lsn than the previous one: if not, then no physical write is done; by setting this parameter TRUE, a physical write will always be made to log files *//********************************************************************Makes a checkpoint at a given lsn or later. */voidlog_make_checkpoint_at(/*===================*/ dulint lsn, /* in: make a checkpoint at this or a later lsn, if ut_dulint_max, makes a checkpoint at the latest lsn */ ibool write_always); /* in: the function normally checks if the the new checkpoint would have a greater lsn than the previous one: if not, then no physical write is done; by setting this parameter TRUE, a physical write will always be made to log files *//********************************************************************Makes a checkpoint at the latest lsn and writes it to first page of eachdata file in the database, so that we know that the file spaces containall modifications up to that lsn. This can only be called at databaseshutdown. This function also writes all log in log files to the log archive. */voidlogs_empty_and_mark_files_at_shutdown(void);/*=======================================*//**********************************************************Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */voidlog_group_read_checkpoint_info(/*===========================*/ log_group_t* group, /* in: log group */ ulint field); /* in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 *//***********************************************************************Gets info from a checkpoint about a log group. */voidlog_checkpoint_get_nth_group_info(/*==============================*/ byte* buf, /* in: buffer containing checkpoint info */ ulint n, /* in: nth slot */ ulint* file_no,/* out: archived file number */ ulint* offset);/* out: archived file offset *//**********************************************************Writes checkpoint info to groups. */voidlog_groups_write_checkpoint_info(void);/*==================================*//**********************************************************Writes info to a buffer of a log group when log files are created inbackup restoration. */voidlog_reset_first_header_and_checkpoint(/*==================================*/ byte* hdr_buf,/* in: buffer which will be written to the start of the first log file */ dulint start); /* in: lsn of the start of the first log file; we pretend that there is a checkpoint at start + LOG_BLOCK_HDR_SIZE *//************************************************************************Starts an archiving operation. */iboollog_archive_do(/*===========*/ /* out: TRUE if succeed, FALSE if an archiving operation was already running */ ibool sync, /* in: TRUE if synchronous operation is desired */ ulint* n_bytes);/* out: archive log buffer size, 0 if nothing to archive *//********************************************************************Writes the log contents to the archive up to the lsn when this function wascalled, and stops the archiving. When archiving is started again, the archivedlog file numbers start from a number one higher, so that the archiving willnot write again to the archived log files which exist when this functionreturns. */ulintlog_archive_stop(void);/*==================*/ /* out: DB_SUCCESS or DB_ERROR *//********************************************************************Starts again archiving which has been stopped. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -