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 "miscadmin.h"
#include "pgstat.h"
#include "utils/memutils.h"
Go to the source code of this file.
Macros | |
#define | MAX_ERRORMSG_LEN 1000 |
#define | COPY_HEADER_FIELD(_dst, _size) |
#define COPY_HEADER_FIELD | ( | _dst, | |
_size | |||
) |
Referenced by DecodeXLogRecord().
#define MAX_ERRORMSG_LEN 1000 |
Definition at line 51 of file xlogreader.c.
Referenced by report_invalid_record(), and XLogReaderAllocate().
|
static |
Definition at line 173 of file xlogreader.c.
References AllocSizeIsValid, Max, MCXT_ALLOC_NO_OOM, palloc_extended(), pfree(), XLogReaderState::readRecordBuf, and XLogReaderState::readRecordBufSize.
Referenced by XLogReaderAllocate(), and XLogReadRecord().
bool DecodeXLogRecord | ( | XLogReaderState * | state, |
XLogRecord * | record, | ||
char ** | errormsg | ||
) |
Definition at line 1173 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_HAS_HOLE, BKPIMAGE_IS_COMPRESSED, DecodedBkpBlock::blkno, XLogReaderState::blocks, COPY_HEADER_FIELD, DecodedBkpBlock::data, DecodedBkpBlock::data_bufsz, DecodedBkpBlock::data_len, XLogReaderState::decoded_record, XLogReaderState::errormsg_buf, DecodedBkpBlock::flags, DecodedBkpBlock::forknum, DecodedBkpBlock::has_data, DecodedBkpBlock::has_image, DecodedBkpBlock::hole_length, DecodedBkpBlock::hole_offset, DecodedBkpBlock::in_use, InvalidRepOriginId, InvalidTransactionId, LSN_FORMAT_ARGS, XLogReaderState::main_data, XLogReaderState::main_data_bufsz, XLogReaderState::main_data_len, Max, XLogReaderState::max_block_id, MAXALIGN, palloc(), pfree(), XLogReaderState::ReadRecPtr, XLogReaderState::record_origin, remaining, report_invalid_record(), ResetDecoder(), DecodedBkpBlock::rnode, SizeOfXLogRecord, XLogReaderState::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 XLogInsertRecord(), and XLogReadRecord().
|
static |
Definition at line 575 of file xlogreader.c.
References Assert, XLogReaderState::currRecPtr, Max, XLogReaderRoutine::page_read, XLogReaderState::readBuf, XLogReaderState::readLen, readLen, XLogReaderState::routine, XLogReaderState::seg, XLogReaderState::segcxt, XLogReaderState::segoff, SizeOfXLogShortPHD, WALOpenSegment::ws_segno, WALSegmentContext::ws_segsize, XLByteToSeg, XLogPageHeaderSize, XLogReaderInvalReadState(), XLogReaderValidatePageHeader(), and XLogSegmentOffset.
Referenced by XLogReaderValidatePageHeader(), and XLogReadRecord().
|
static |
Definition at line 58 of file xlogreader.c.
References _, generate_unaccent_rules::args, XLogReaderState::errormsg_buf, MAX_ERRORMSG_LEN, and vsnprintf.
Referenced by DecodeXLogRecord(), RestoreBlockImage(), ValidXLogRecord(), ValidXLogRecordHeader(), XLogReaderValidatePageHeader(), and XLogReadRecord().
|
static |
Definition at line 1148 of file xlogreader.c.
References DecodedBkpBlock::apply_image, XLogReaderState::blocks, XLogReaderState::decoded_record, DecodedBkpBlock::has_data, DecodedBkpBlock::has_image, DecodedBkpBlock::in_use, XLogReaderState::main_data_len, and XLogReaderState::max_block_id.
Referenced by DecodeXLogRecord(), XLogBeginRead(), and XLogReadRecord().
bool RestoreBlockImage | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
char * | page | ||
) |
Definition at line 1544 of file xlogreader.c.
References DecodedBkpBlock::bimg_info, DecodedBkpBlock::bimg_len, DecodedBkpBlock::bkp_image, BKPIMAGE_IS_COMPRESSED, XLogReaderState::blocks, PGAlignedBlock::data, DecodedBkpBlock::has_image, DecodedBkpBlock::hole_length, DecodedBkpBlock::hole_offset, DecodedBkpBlock::in_use, LSN_FORMAT_ARGS, MemSet, pglz_decompress(), XLogReaderState::ReadRecPtr, and report_invalid_record().
Referenced by checkXLogConsistency(), and XLogReadBufferForRedoExtended().
|
static |
Definition at line 754 of file xlogreader.c.
References COMP_CRC32C, EQ_CRC32C, FIN_CRC32C, INIT_CRC32C, LSN_FORMAT_ARGS, offsetof, report_invalid_record(), and SizeOfXLogRecord.
Referenced by XLogReadRecord().
|
static |
Definition at line 688 of file xlogreader.c.
References LSN_FORMAT_ARGS, report_invalid_record(), RM_MAX_ID, SizeOfXLogRecord, XLogRecord::xl_prev, XLogRecord::xl_rmid, and XLogRecord::xl_tot_len.
Referenced by XLogReadRecord().
|
static |
Definition at line 216 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 1059 of file xlogreader.c.
References Assert, buf, pg_pread(), pgstat_report_wait_end(), pgstat_report_wait_start(), XLogReaderState::routine, XLogReaderState::seg, XLogReaderState::segcxt, XLogReaderRoutine::segment_close, XLogReaderRoutine::segment_open, startptr, WAIT_EVENT_WAL_READ, WALReadError::wre_errno, WALReadError::wre_off, WALReadError::wre_read, WALReadError::wre_req, WALReadError::wre_seg, WALOpenSegment::ws_file, WALOpenSegment::ws_segno, WALSegmentContext::ws_segsize, WALOpenSegment::ws_tli, XLByteInSeg, XLByteToSeg, and XLogSegmentOffset.
Referenced by logical_read_xlog_page(), read_local_xlog_page(), WALDumpReadPage(), and XLogSendPhysical().
void XLogBeginRead | ( | XLogReaderState * | state, |
XLogRecPtr | RecPtr | ||
) |
Definition at line 240 of file xlogreader.c.
References Assert, XLogReaderState::EndRecPtr, InvalidXLogRecPtr, XLogReaderState::ReadRecPtr, ResetDecoder(), and XLogRecPtrIsInvalid.
Referenced by DecodingContextFindStartpoint(), extractPageMap(), findLastCheckpoint(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), ReadCheckpointRecord(), readOneRecord(), StartLogicalReplication(), StartupXLOG(), XLogReaderValidatePageHeader(), and XlogReadTwoPhaseData().
XLogReaderState* XLogReaderAllocate | ( | int | wal_segment_size, |
const char * | waldir, | ||
XLogReaderRoutine * | routine, | ||
void * | private_data | ||
) |
Definition at line 75 of file xlogreader.c.
References allocate_recordbuf(), XLogReaderState::errormsg_buf, XLogReaderState::max_block_id, MAX_ERRORMSG_LEN, MCXT_ALLOC_NO_OOM, MCXT_ALLOC_ZERO, palloc_extended(), pfree(), XLogReaderState::private_data, XLogReaderState::readBuf, XLogReaderState::routine, XLogReaderState::seg, XLogReaderState::segcxt, and WALOpenSegmentInit().
Referenced by extractPageMap(), findLastCheckpoint(), main(), readOneRecord(), StartReplication(), StartupDecodingContext(), StartupXLOG(), XLogInsertRecord(), and XlogReadTwoPhaseData().
void XLogReaderFree | ( | XLogReaderState * | state | ) |
Definition at line 139 of file xlogreader.c.
References XLogReaderState::blocks, DecodedBkpBlock::data, XLogReaderState::errormsg_buf, XLogReaderState::main_data, pfree(), XLogReaderState::readBuf, XLogReaderState::readRecordBuf, XLogReaderState::routine, XLogReaderState::seg, XLogReaderRoutine::segment_close, WALOpenSegment::ws_file, and XLR_MAX_BLOCK_ID.
Referenced by extractPageMap(), findLastCheckpoint(), FreeDecodingContext(), main(), readOneRecord(), StartupXLOG(), and XlogReadTwoPhaseData().
|
static |
Definition at line 674 of file xlogreader.c.
References XLogReaderState::readLen, XLogReaderState::seg, XLogReaderState::segoff, and WALOpenSegment::ws_segno.
Referenced by ReadPageInternal(), XLogReaderValidatePageHeader(), and XLogReadRecord().
bool XLogReaderValidatePageHeader | ( | XLogReaderState * | state, |
XLogRecPtr | recptr, | ||
char * | phdr | ||
) |
Definition at line 783 of file xlogreader.c.
References Assert, header(), InvalidXLogRecPtr, XLogReaderState::latestPagePtr, XLogReaderState::latestPageTLI, LSN_FORMAT_ARGS, MAXALIGN, MAXFNAMELEN, XLogReaderState::readBuf, readLen, ReadPageInternal(), XLogReaderState::ReadRecPtr, ReadRecPtr, report_invalid_record(), XLogReaderState::seg, XLogReaderState::segcxt, XLogReaderState::system_identifier, WALSegmentContext::ws_segsize, WALOpenSegment::ws_tli, XLByteToSeg, XLOG_PAGE_MAGIC, XLogBeginRead(), XLogFileName, XLogPageHeaderSize, XLogReaderInvalReadState(), XLogReadRecord(), XLogRecPtrIsInvalid, XLogSegmentOffset, XLogSegNoOffsetToRecPtr, XLP_ALL_FLAGS, XLP_FIRST_IS_CONTRECORD, XLogPageHeaderData::xlp_info, XLP_LONG_HEADER, XLogPageHeaderData::xlp_magic, XLogPageHeaderData::xlp_pageaddr, XLogPageHeaderData::xlp_rem_len, 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 268 of file xlogreader.c.
References allocate_recordbuf(), Assert, XLogReaderState::currRecPtr, DecodeXLogRecord(), XLogReaderState::EndRecPtr, XLogReaderState::errormsg_buf, InvalidXLogRecPtr, LSN_FORMAT_ARGS, MAXALIGN, Min, XLogReaderState::readBuf, readOff, ReadPageInternal(), XLogReaderState::readRecordBuf, XLogReaderState::readRecordBufSize, XLogReaderState::ReadRecPtr, report_invalid_record(), ResetDecoder(), XLogReaderState::segcxt, SizeOfXLogRecord, SizeOfXLogShortPHD, ValidXLogRecord(), ValidXLogRecordHeader(), WALSegmentContext::ws_segsize, XLogRecord::xl_info, XLogRecord::xl_rmid, XLogRecord::xl_tot_len, XLOG_SWITCH, XLogPageHeaderSize, XLogReaderInvalReadState(), XLogSegmentOffset, XLP_FIRST_IS_CONTRECORD, XLogPageHeaderData::xlp_info, XLogPageHeaderData::xlp_rem_len, XLR_INFO_MASK, and XRecOffIsValid.
Referenced by DecodingContextFindStartpoint(), extractPageMap(), findLastCheckpoint(), main(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), readOneRecord(), ReadRecord(), XLogReaderValidatePageHeader(), XlogReadTwoPhaseData(), and XLogSendLogical().
char* XLogRecGetBlockData | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
Size * | len | ||
) |
Definition at line 1515 of file xlogreader.c.
References XLogReaderState::blocks, DecodedBkpBlock::data, DecodedBkpBlock::data_len, DecodedBkpBlock::has_data, and DecodedBkpBlock::in_use.
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(), heap_xlog_clean(), heap_xlog_freeze_page(), heap_xlog_inplace(), heap_xlog_insert(), heap_xlog_multi_insert(), and heap_xlog_update().
bool XLogRecGetBlockTag | ( | XLogReaderState * | record, |
uint8 | block_id, | ||
RelFileNode * | rnode, | ||
ForkNumber * | forknum, | ||
BlockNumber * | blknum | ||
) |
Definition at line 1491 of file xlogreader.c.
References DecodedBkpBlock::blkno, XLogReaderState::blocks, DecodedBkpBlock::forknum, DecodedBkpBlock::in_use, and DecodedBkpBlock::rnode.
Referenced by brin_xlog_revmap_extend(), btree_xlog_delete(), btree_xlog_split(), checkXLogConsistency(), DecodeDelete(), DecodeInsert(), DecodeMultiInsert(), DecodeSpecConfirm(), DecodeUpdate(), extractPageInfo(), gistRedoDeleteRecord(), gistRedoPageSplitRecord(), hash_xlog_add_ovfl_page(), hash_xlog_init_bitmap_page(), hash_xlog_init_meta_page(), hash_xlog_vacuum_one_page(), heap_xlog_clean(), heap_xlog_delete(), heap_xlog_freeze_page(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_lock_updated(), heap_xlog_multi_insert(), heap_xlog_update(), heap_xlog_visible(), spgRedoAddLeaf(), spgRedoAddNode(), spgRedoMoveLeafs(), spgRedoPickSplit(), spgRedoVacuumRedirect(), xlog_block_info(), XLogDumpDisplayRecord(), and XLogReadBufferForRedoExtended().
FullTransactionId XLogRecGetFullXid | ( | XLogReaderState * | record | ) |
Definition at line 1596 of file xlogreader.c.
References AmStartupProcess, Assert, epoch, EpochFromFullTransactionId, FullTransactionIdFromEpochAndXid(), IsUnderPostmaster, VariableCacheData::nextXid, ShmemVariableCache, unlikely, XidFromFullTransactionId, and XLogRecGetXid.