PostgreSQL Source Code git master
|
Go to the source code of this file.
Data Structures | |
struct | WALOpenSegment |
struct | WALSegmentContext |
struct | XLogReaderRoutine |
struct | DecodedBkpBlock |
struct | DecodedXLogRecord |
struct | XLogReaderState |
struct | WALReadError |
Macros | |
#define | XL_ROUTINE(...) &(XLogReaderRoutine){__VA_ARGS__} |
#define | XLogRecGetTotalLen(decoder) ((decoder)->record->header.xl_tot_len) |
#define | XLogRecGetPrev(decoder) ((decoder)->record->header.xl_prev) |
#define | XLogRecGetInfo(decoder) ((decoder)->record->header.xl_info) |
#define | XLogRecGetRmid(decoder) ((decoder)->record->header.xl_rmid) |
#define | XLogRecGetXid(decoder) ((decoder)->record->header.xl_xid) |
#define | XLogRecGetOrigin(decoder) ((decoder)->record->record_origin) |
#define | XLogRecGetTopXid(decoder) ((decoder)->record->toplevel_xid) |
#define | XLogRecGetData(decoder) ((decoder)->record->main_data) |
#define | XLogRecGetDataLen(decoder) ((decoder)->record->main_data_len) |
#define | XLogRecHasAnyBlockRefs(decoder) ((decoder)->record->max_block_id >= 0) |
#define | XLogRecMaxBlockId(decoder) ((decoder)->record->max_block_id) |
#define | XLogRecGetBlock(decoder, i) (&(decoder)->record->blocks[(i)]) |
#define | XLogRecHasBlockRef(decoder, block_id) |
#define | XLogRecHasBlockImage(decoder, block_id) ((decoder)->record->blocks[block_id].has_image) |
#define | XLogRecBlockImageApply(decoder, block_id) ((decoder)->record->blocks[block_id].apply_image) |
#define | XLogRecHasBlockData(decoder, block_id) ((decoder)->record->blocks[block_id].has_data) |
Typedefs | |
typedef struct WALOpenSegment | WALOpenSegment |
typedef struct WALSegmentContext | WALSegmentContext |
typedef struct XLogReaderState | XLogReaderState |
typedef int(* | XLogPageReadCB) (XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *readBuf) |
typedef void(* | WALSegmentOpenCB) (XLogReaderState *xlogreader, XLogSegNo nextSegNo, TimeLineID *tli_p) |
typedef void(* | WALSegmentCloseCB) (XLogReaderState *xlogreader) |
typedef struct XLogReaderRoutine | XLogReaderRoutine |
typedef struct DecodedXLogRecord | DecodedXLogRecord |
typedef enum XLogPageReadResult | XLogPageReadResult |
typedef struct WALReadError | WALReadError |
Enumerations | |
enum | XLogPageReadResult { XLREAD_SUCCESS = 0 , XLREAD_FAIL = -1 , XLREAD_WOULDBLOCK = -2 } |
#define XL_ROUTINE | ( | ... | ) | &(XLogReaderRoutine){__VA_ARGS__} |
Definition at line 117 of file xlogreader.h.
#define XLogRecBlockImageApply | ( | decoder, | |
block_id | |||
) | ((decoder)->record->blocks[block_id].apply_image) |
Definition at line 425 of file xlogreader.h.
Definition at line 419 of file xlogreader.h.
#define XLogRecGetData | ( | decoder | ) | ((decoder)->record->main_data) |
Definition at line 415 of file xlogreader.h.
#define XLogRecGetDataLen | ( | decoder | ) | ((decoder)->record->main_data_len) |
Definition at line 416 of file xlogreader.h.
#define XLogRecGetInfo | ( | decoder | ) | ((decoder)->record->header.xl_info) |
Definition at line 410 of file xlogreader.h.
#define XLogRecGetOrigin | ( | decoder | ) | ((decoder)->record->record_origin) |
Definition at line 413 of file xlogreader.h.
#define XLogRecGetPrev | ( | decoder | ) | ((decoder)->record->header.xl_prev) |
Definition at line 409 of file xlogreader.h.
#define XLogRecGetRmid | ( | decoder | ) | ((decoder)->record->header.xl_rmid) |
Definition at line 411 of file xlogreader.h.
#define XLogRecGetTopXid | ( | decoder | ) | ((decoder)->record->toplevel_xid) |
Definition at line 414 of file xlogreader.h.
#define XLogRecGetTotalLen | ( | decoder | ) | ((decoder)->record->header.xl_tot_len) |
Definition at line 408 of file xlogreader.h.
#define XLogRecGetXid | ( | decoder | ) | ((decoder)->record->header.xl_xid) |
Definition at line 412 of file xlogreader.h.
#define XLogRecHasAnyBlockRefs | ( | decoder | ) | ((decoder)->record->max_block_id >= 0) |
Definition at line 417 of file xlogreader.h.
#define XLogRecHasBlockData | ( | decoder, | |
block_id | |||
) | ((decoder)->record->blocks[block_id].has_data) |
Definition at line 427 of file xlogreader.h.
#define XLogRecHasBlockImage | ( | decoder, | |
block_id | |||
) | ((decoder)->record->blocks[block_id].has_image) |
Definition at line 423 of file xlogreader.h.
#define XLogRecHasBlockRef | ( | decoder, | |
block_id | |||
) |
Definition at line 420 of file xlogreader.h.
#define XLogRecMaxBlockId | ( | decoder | ) | ((decoder)->record->max_block_id) |
Definition at line 418 of file xlogreader.h.
typedef struct DecodedXLogRecord DecodedXLogRecord |
typedef struct WALOpenSegment WALOpenSegment |
typedef struct WALReadError WALReadError |
typedef void(* WALSegmentCloseCB) (XLogReaderState *xlogreader) |
Definition at line 70 of file xlogreader.h.
typedef struct WALSegmentContext WALSegmentContext |
typedef void(* WALSegmentOpenCB) (XLogReaderState *xlogreader, XLogSegNo nextSegNo, TimeLineID *tli_p) |
Definition at line 67 of file xlogreader.h.
typedef int(* XLogPageReadCB) (XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *readBuf) |
Definition at line 62 of file xlogreader.h.
typedef enum XLogPageReadResult XLogPageReadResult |
typedef struct XLogReaderRoutine XLogReaderRoutine |
typedef struct XLogReaderState XLogReaderState |
Definition at line 59 of file xlogreader.h.
enum XLogPageReadResult |
Enumerator | |
---|---|
XLREAD_SUCCESS | |
XLREAD_FAIL | |
XLREAD_WOULDBLOCK |
Definition at line 349 of file xlogreader.h.
bool DecodeXLogRecord | ( | XLogReaderState * | state, |
DecodedXLogRecord * | decoded, | ||
XLogRecord * | record, | ||
XLogRecPtr | lsn, | ||
char ** | errormsg | ||
) |
Definition at line 1662 of file xlogreader.c.
References DecodedBkpBlock::apply_image, Assert, DecodedBkpBlock::bimg_info, DecodedBkpBlock::bimg_len, DecodedBkpBlock::bkp_image, BKPBLOCK_FORK_MASK, BKPBLOCK_HAS_DATA, BKPBLOCK_HAS_IMAGE, BKPBLOCK_SAME_REL, BKPIMAGE_APPLY, BKPIMAGE_COMPRESSED, BKPIMAGE_HAS_HOLE, DecodedBkpBlock::blkno, DecodedXLogRecord::blocks, COPY_HEADER_FIELD, DecodedBkpBlock::data, DecodedBkpBlock::data_len, DecodeXLogRecordRequiredSpace(), err(), DecodedBkpBlock::flags, DecodedBkpBlock::forknum, DecodedBkpBlock::has_data, DecodedBkpBlock::has_image, DecodedXLogRecord::header, DecodedBkpBlock::hole_length, DecodedBkpBlock::hole_offset, i, DecodedBkpBlock::in_use, InvalidBuffer, InvalidRepOriginId, InvalidTransactionId, DecodedXLogRecord::lsn, LSN_FORMAT_ARGS, DecodedXLogRecord::main_data, DecodedXLogRecord::main_data_len, DecodedXLogRecord::max_block_id, MAXALIGN, DecodedXLogRecord::next, DecodedBkpBlock::prefetch_buffer, DecodedXLogRecord::record_origin, remaining, report_invalid_record(), DecodedBkpBlock::rlocator, DecodedXLogRecord::size, SizeOfXLogRecord, DecodedXLogRecord::toplevel_xid, XLogRecord::xl_tot_len, XLR_BLOCK_ID_DATA_LONG, XLR_BLOCK_ID_DATA_SHORT, XLR_BLOCK_ID_ORIGIN, XLR_BLOCK_ID_TOPLEVEL_XID, and XLR_MAX_BLOCK_ID.
Referenced by XLogDecodeNextRecord(), and XLogInsertRecord().
size_t DecodeXLogRecordRequiredSpace | ( | size_t | xl_tot_len | ) |
Definition at line 1629 of file xlogreader.c.
References size, and XLR_MAX_BLOCK_ID.
Referenced by DecodeXLogRecord(), InitXLogInsert(), XLogInsertRecord(), and XLogReadRecordAlloc().
bool RestoreBlockImage | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
char * | page | ||
) |
Definition at line 2056 of file xlogreader.c.
References DecodedBkpBlock::bimg_info, DecodedBkpBlock::bimg_len, DecodedBkpBlock::bkp_image, BKPIMAGE_COMPRESS_LZ4, BKPIMAGE_COMPRESS_PGLZ, BKPIMAGE_COMPRESS_ZSTD, BKPIMAGE_COMPRESSED, DecodedXLogRecord::blocks, PGAlignedBlock::data, DecodedBkpBlock::has_image, DecodedBkpBlock::hole_length, DecodedBkpBlock::hole_offset, DecodedBkpBlock::in_use, LSN_FORMAT_ARGS, DecodedXLogRecord::max_block_id, MemSet, pglz_decompress(), XLogReaderState::ReadRecPtr, XLogReaderState::record, and report_invalid_record().
Referenced by GetWALBlockInfo(), verifyBackupPageConsistency(), XLogReadBufferForRedoExtended(), and XLogRecordSaveFPWs().
bool WALRead | ( | XLogReaderState * | state, |
char * | buf, | ||
XLogRecPtr | startptr, | ||
Size | count, | ||
TimeLineID | tli, | ||
WALReadError * | errinfo | ||
) |
Definition at line 1503 of file xlogreader.c.
References Assert, buf, pg_pread, pgstat_report_wait_end(), pgstat_report_wait_start(), WALReadError::wre_errno, WALReadError::wre_off, WALReadError::wre_read, WALReadError::wre_req, WALReadError::wre_seg, XLByteInSeg, XLByteToSeg, and XLogSegmentOffset.
Referenced by logical_read_xlog_page(), read_local_xlog_page_guts(), summarizer_read_local_xlog_page(), WALDumpReadPage(), and XLogSendPhysical().
void XLogBeginRead | ( | XLogReaderState * | state, |
XLogRecPtr | RecPtr | ||
) |
Definition at line 231 of file xlogreader.c.
References Assert, InvalidXLogRecPtr, ResetDecoder(), and XLogRecPtrIsInvalid.
Referenced by DecodingContextFindStartpoint(), extractPageMap(), findLastCheckpoint(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), readOneRecord(), StartLogicalReplication(), SummarizeWAL(), XLogFindNextRecord(), XLogPrefetcherBeginRead(), and XlogReadTwoPhaseData().
XLogRecPtr XLogFindNextRecord | ( | XLogReaderState * | state, |
XLogRecPtr | RecPtr | ||
) |
Definition at line 1383 of file xlogreader.c.
References Assert, err(), InvalidXLogRecPtr, MAXALIGN, readLen, ReadPageInternal(), XLogBeginRead(), XLogPageHeaderSize, XLogReaderInvalReadState(), XLogReadRecord(), XLogRecPtrIsInvalid, XLP_FIRST_IS_CONTRECORD, XLogPageHeaderData::xlp_info, and XLogPageHeaderData::xlp_rem_len.
Referenced by InitXLogReaderState(), main(), and SummarizeWAL().
DecodedXLogRecord * XLogNextRecord | ( | XLogReaderState * | state, |
char ** | errormsg | ||
) |
Definition at line 325 of file xlogreader.c.
References Assert, XLogRecPtrIsInvalid, and XLogReleasePreviousRecord().
Referenced by XLogPrefetcherReadRecord(), and XLogReadRecord().
DecodedXLogRecord * XLogReadAhead | ( | XLogReaderState * | state, |
bool | nonblocking | ||
) |
Definition at line 966 of file xlogreader.c.
References Assert, XLogDecodeNextRecord(), and XLREAD_SUCCESS.
Referenced by XLogPrefetcherNextBlock(), and XLogReadRecord().
XLogReaderState * XLogReaderAllocate | ( | int | wal_segment_size, |
const char * | waldir, | ||
XLogReaderRoutine * | routine, | ||
void * | private_data | ||
) |
Definition at line 106 of file xlogreader.c.
References allocate_recordbuf(), MAX_ERRORMSG_LEN, MCXT_ALLOC_NO_OOM, MCXT_ALLOC_ZERO, palloc_extended(), pfree(), wal_segment_size, and WALOpenSegmentInit().
Referenced by extractPageMap(), findLastCheckpoint(), InitWalRecovery(), InitXLogReaderState(), main(), readOneRecord(), StartReplication(), StartupDecodingContext(), SummarizeWAL(), XLogInsertRecord(), and XlogReadTwoPhaseData().
void XLogReaderFree | ( | XLogReaderState * | state | ) |
Definition at line 161 of file xlogreader.c.
References pfree().
Referenced by extractPageMap(), findLastCheckpoint(), FreeDecodingContext(), GetWALRecordsInfo(), main(), pg_get_wal_block_info(), pg_get_wal_record_info(), readOneRecord(), ShutdownWalRecovery(), SummarizeWAL(), and XlogReadTwoPhaseData().
|
inlinestatic |
Definition at line 325 of file xlogreader.h.
Referenced by XLogPrefetcherNextBlock(), XLogPrefetcherReadRecord(), and XLogReadRecord().
void XLogReaderResetError | ( | XLogReaderState * | state | ) |
Definition at line 1365 of file xlogreader.c.
Referenced by XLogPageRead().
void XLogReaderSetDecodeBuffer | ( | XLogReaderState * | state, |
void * | buffer, | ||
size_t | size | ||
) |
Definition at line 90 of file xlogreader.c.
Referenced by InitWalRecovery().
bool XLogReaderValidatePageHeader | ( | XLogReaderState * | state, |
XLogRecPtr | recptr, | ||
char * | phdr | ||
) |
Definition at line 1224 of file xlogreader.c.
References Assert, LSN_FORMAT_ARGS, MAXFNAMELEN, report_invalid_record(), XLByteToSeg, XLOG_PAGE_MAGIC, XLogFileName(), XLogSegmentOffset, XLP_ALL_FLAGS, XLogPageHeaderData::xlp_info, XLP_LONG_HEADER, XLogPageHeaderData::xlp_magic, XLogPageHeaderData::xlp_pageaddr, XLogLongPageHeaderData::xlp_seg_size, XLogLongPageHeaderData::xlp_sysid, XLogPageHeaderData::xlp_tli, and XLogLongPageHeaderData::xlp_xlog_blcksz.
Referenced by ReadPageInternal(), and XLogPageRead().
struct XLogRecord * XLogReadRecord | ( | XLogReaderState * | state, |
char ** | errormsg | ||
) |
Definition at line 389 of file xlogreader.c.
References Assert, DecodedXLogRecord::header, XLogNextRecord(), XLogReadAhead(), XLogReaderHasQueuedRecordOrError(), and XLogReleasePreviousRecord().
Referenced by DecodingContextFindStartpoint(), extractPageMap(), findLastCheckpoint(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), main(), pg_logical_slot_get_changes_guts(), ReadNextXLogRecord(), readOneRecord(), SummarizeWAL(), XLogFindNextRecord(), XlogReadTwoPhaseData(), and XLogSendLogical().
char * XLogRecGetBlockData | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
Size * | len | ||
) |
Definition at line 2025 of file xlogreader.c.
References DecodedXLogRecord::blocks, DecodedBkpBlock::data, DecodedBkpBlock::data_len, DecodedBkpBlock::has_data, DecodedBkpBlock::in_use, len, DecodedXLogRecord::max_block_id, and XLogReaderState::record.
Referenced by _bt_restore_meta(), brin_xlog_insert_update(), brin_xlog_samepage_update(), btree_desc(), btree_xlog_dedup(), btree_xlog_delete(), btree_xlog_insert(), btree_xlog_newroot(), btree_xlog_split(), btree_xlog_vacuum(), DecodeInsert(), DecodeMultiInsert(), DecodeUpdate(), generic_redo(), gin_desc(), ginRedoInsert(), ginRedoInsertListPage(), ginRedoUpdateMetapage(), ginRedoVacuumDataLeafPage(), gistRedoPageSplitRecord(), gistRedoPageUpdateRecord(), hash_xlog_add_ovfl_page(), hash_xlog_delete(), hash_xlog_insert(), hash_xlog_move_page_contents(), hash_xlog_split_allocate_page(), hash_xlog_squeeze_page(), heap2_desc(), heap_xlog_inplace(), heap_xlog_insert(), heap_xlog_multi_insert(), heap_xlog_prune_freeze(), and heap_xlog_update().
void XLogRecGetBlockTag | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
RelFileLocator * | rlocator, | ||
ForkNumber * | forknum, | ||
BlockNumber * | blknum | ||
) |
Definition at line 1971 of file xlogreader.c.
References elog, ERROR, pg_fatal, and XLogRecGetBlockTagExtended().
Referenced by brin_xlog_revmap_extend(), btree_xlog_delete(), btree_xlog_split(), DecodeDelete(), DecodeInsert(), DecodeMultiInsert(), DecodeSpecConfirm(), DecodeUpdate(), gistRedoDeleteRecord(), gistRedoPageSplitRecord(), hash_xlog_add_ovfl_page(), hash_xlog_init_bitmap_page(), hash_xlog_init_meta_page(), hash_xlog_vacuum_one_page(), heap_xlog_delete(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_prune_freeze(), heap_xlog_update(), heap_xlog_visible(), spgRedoAddLeaf(), spgRedoAddNode(), spgRedoMoveLeafs(), spgRedoPickSplit(), and spgRedoVacuumRedirect().
bool XLogRecGetBlockTagExtended | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
RelFileLocator * | rlocator, | ||
ForkNumber * | forknum, | ||
BlockNumber * | blknum, | ||
Buffer * | prefetch_buffer | ||
) |
Definition at line 1997 of file xlogreader.c.
References DecodedBkpBlock::blkno, DecodedXLogRecord::blocks, DecodedBkpBlock::forknum, DecodedBkpBlock::prefetch_buffer, XLogReaderState::record, DecodedBkpBlock::rlocator, and XLogRecHasBlockRef.
Referenced by btree_xlog_split(), extractPageInfo(), GetWALBlockInfo(), heap_xlog_update(), SummarizeWAL(), verifyBackupPageConsistency(), xlog_block_info(), XLogReadBufferForRedoExtended(), XLogRecGetBlockRefInfo(), XLogRecGetBlockTag(), XLogRecordMatchesRelationBlock(), and XLogRecordSaveFPWs().
FullTransactionId XLogRecGetFullXid | ( | XLogReaderState * | record | ) |
Definition at line 2167 of file xlogreader.c.
References AmStartupProcess, Assert, epoch, EpochFromFullTransactionId, FullTransactionIdFromEpochAndXid(), IsUnderPostmaster, TransamVariablesData::nextXid, TransamVariables, unlikely, XidFromFullTransactionId, and XLogRecGetXid.
XLogRecPtr XLogReleasePreviousRecord | ( | XLogReaderState * | state | ) |
Definition at line 249 of file xlogreader.c.
References Assert, InvalidXLogRecPtr, DecodedXLogRecord::next, DecodedXLogRecord::next_lsn, DecodedXLogRecord::oversized, pfree(), and unlikely.
Referenced by XLogNextRecord(), XLogPrefetcherReadRecord(), and XLogReadRecord().