PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <unistd.h>
#include "access/transam.h"
#include "access/xlog_internal.h"
#include "access/xlogreader.h"
#include "access/xlogrecord.h"
#include "catalog/pg_control.h"
#include "common/pg_lzcompress.h"
#include "replication/origin.h"
#include "pgstat.h"
Go to the source code of this file.
Macros | |
#define | MAX_ERRORMSG_LEN 1000 |
#define | DEFAULT_DECODE_BUFFER_SIZE (64 * 1024) |
#define | COPY_HEADER_FIELD(_dst, _size) |
#define COPY_HEADER_FIELD | ( | _dst, | |
_size | |||
) |
#define DEFAULT_DECODE_BUFFER_SIZE (64 * 1024) |
Definition at line 64 of file xlogreader.c.
#define MAX_ERRORMSG_LEN 1000 |
Definition at line 58 of file xlogreader.c.
|
static |
Definition at line 190 of file xlogreader.c.
References Max, palloc(), and pfree().
Referenced by XLogDecodeNextRecord(), and XLogReaderAllocate().
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().
|
static |
Definition at line 1000 of file xlogreader.c.
References Assert, err(), if(), Max, readLen, SizeOfXLogShortPHD, XLByteToSeg, XLogPageHeaderSize, XLogReaderInvalReadState(), XLogReaderValidatePageHeader(), XLogSegmentOffset, XLREAD_FAIL, and XLREAD_WOULDBLOCK.
Referenced by XLogDecodeNextRecord(), and XLogFindNextRecord().
|
static |
Definition at line 71 of file xlogreader.c.
References _, generate_unaccent_rules::args, fmt, MAX_ERRORMSG_LEN, va_end(), va_start(), and vsnprintf.
Referenced by DecodeXLogRecord(), RestoreBlockImage(), ValidXLogRecord(), ValidXLogRecordHeader(), XLogDecodeNextRecord(), and XLogReaderValidatePageHeader().
|
static |
Definition at line 1595 of file xlogreader.c.
References DecodedXLogRecord::next, DecodedXLogRecord::oversized, and pfree().
Referenced by XLogBeginRead().
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().
|
static |
Definition at line 1193 of file xlogreader.c.
References Assert, COMP_CRC32C, crc, EQ_CRC32C, FIN_CRC32C, INIT_CRC32C, LSN_FORMAT_ARGS, report_invalid_record(), SizeOfXLogRecord, XLogRecord::xl_crc, and XLogRecord::xl_tot_len.
Referenced by XLogDecodeNextRecord().
|
static |
Definition at line 1127 of file xlogreader.c.
References LSN_FORMAT_ARGS, report_invalid_record(), RmgrIdIsValid, SizeOfXLogRecord, XLogRecord::xl_prev, XLogRecord::xl_rmid, and XLogRecord::xl_tot_len.
Referenced by XLogDecodeNextRecord().
|
static |
Definition at line 207 of file xlogreader.c.
References MAXPGPATH, snprintf, WALSegmentContext::ws_dir, WALOpenSegment::ws_file, WALOpenSegment::ws_segno, WALSegmentContext::ws_segsize, and WALOpenSegment::ws_tli.
Referenced by XLogReaderAllocate().
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().
|
static |
Definition at line 528 of file xlogreader.c.
References allocate_recordbuf(), Assert, DecodeXLogRecord(), err(), if(), InvalidXLogRecPtr, len, lengthof, LSN_FORMAT_ARGS, MAXALIGN, Min, state::next, DecodedXLogRecord::next_lsn, DecodedXLogRecord::oversized, pfree(), readOff, ReadPageInternal(), report_invalid_record(), DecodedXLogRecord::size, SizeOfXLogRecord, SizeOfXLogShortPHD, ValidXLogRecord(), ValidXLogRecordHeader(), XLogRecord::xl_info, XLogRecord::xl_rmid, XLogRecord::xl_tot_len, XLOG_SWITCH, XLogPageHeaderSize, XLogReaderInvalReadState(), XLogReadRecordAlloc(), XLogSegmentOffset, XLP_FIRST_IS_CONTRECORD, XLP_FIRST_IS_OVERWRITE_CONTRECORD, XLogPageHeaderData::xlp_info, XLogPageHeaderData::xlp_rem_len, XLR_INFO_MASK, XLREAD_FAIL, XLREAD_SUCCESS, XLREAD_WOULDBLOCK, and XRecOffIsValid.
Referenced by XLogReadAhead().
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().
|
static |
Definition at line 1113 of file xlogreader.c.
Referenced by ReadPageInternal(), XLogDecodeNextRecord(), and XLogFindNextRecord().
void XLogReaderResetError | ( | XLogReaderState * | state | ) |
Definition at line 1365 of file xlogreader.c.
Referenced by XLogPageRead().
void XLogReaderSetDecodeBuffer | ( | XLogReaderState * | state, |
void * | buffer, | ||
size_t | size | ||
) |
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().
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().
|
static |
Definition at line 438 of file xlogreader.c.
References DecodeXLogRecordRequiredSpace(), DEFAULT_DECODE_BUFFER_SIZE, DecodedXLogRecord::oversized, palloc(), and unlikely.
Referenced by XLogDecodeNextRecord().
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().