/* WALOpenSegment represents a WAL segment being read. */ typedefstruct WALOpenSegment
{ int ws_file; /* segment file descriptor */
XLogSegNo ws_segno; /* segment number */
TimeLineID ws_tli; /* timeline ID of the currently open file */
} WALOpenSegment;
/* WALSegmentContext carries context information about WAL segments to read */ typedefstruct WALSegmentContext
{ char ws_dir[MAXPGPATH]; int ws_segsize;
} WALSegmentContext;
typedefstruct XLogReaderState XLogReaderState;
/* Function type definitions for various xlogreader interactions */ typedefint (*XLogPageReadCB) (XLogReaderState *xlogreader,
XLogRecPtr targetPagePtr, int reqLen,
XLogRecPtr targetRecPtr, char *readBuf); typedefvoid (*WALSegmentOpenCB) (XLogReaderState *xlogreader,
XLogSegNo nextSegNo,
TimeLineID *tli_p); typedefvoid (*WALSegmentCloseCB) (XLogReaderState *xlogreader);
/* copy of the fork_flags field from the XLogRecordBlockHeader */
uint8 flags;
/* Information on full-page image, if any */ bool has_image; /* has image, even for consistency checking */ bool apply_image; /* has image that should be restored */ char *bkp_image;
uint16 hole_offset;
uint16 hole_length;
uint16 bimg_len;
uint8 bimg_info;
/* Buffer holding the rmgr-specific data associated with this block */ bool has_data; char *data;
uint16 data_len;
uint16 data_bufsz;
} DecodedBkpBlock;
/* *Thedecodedcontentsofarecord.Thisoccupiesacontiguousregionof *memory,withmain_dataandblocks[n].datapointingtomemoryafterthe *membersdeclaredhere.
*/ typedefstruct DecodedXLogRecord
{ /* Private member used for resource management. */
size_t size; /* total size of decoded record */ bool oversized; /* outside the regular decode buffer? */ struct DecodedXLogRecord *next; /* decoded record queue link */
/* Public members. */
XLogRecPtr lsn; /* location */
XLogRecPtr next_lsn; /* location of next record */
XLogRecord header; /* header */
RepOriginId record_origin;
TransactionId toplevel_xid; /* XID of top-level transaction */ char *main_data; /* record's main data portion */
uint32 main_data_len; /* main data portion's length */ int max_block_id; /* highest block_id in use (-1 if none) */
DecodedBkpBlock blocks[FLEXIBLE_ARRAY_MEMBER];
} DecodedXLogRecord;
/* *Startandendpointoflastrecordread.EndRecPtrisalsousedasthe *positiontoreadnext.CallingXLogBeginRead()setsEndRecPtrtothe *startingpositionandReadRecPtrtoinvalid. * *StartandendpointoflastrecordreturnedbyXLogReadRecord().These *arealsoavailableasrecord->lsnandrecord->next_lsn.
*/
XLogRecPtr ReadRecPtr; /* start of last record read */
XLogRecPtr EndRecPtr; /* end+1 of last record read */
/* *Setattheendofrecovery:thestartpointofapartialrecordatthe *endofWAL(InvalidXLogRecPtriftherewasn'tone),andthestart *locationofitsfirstcontrecordthatwentmissing.
*/
XLogRecPtr abortedRecPtr;
XLogRecPtr missingContrecPtr; /* Set when XLP_FIRST_IS_OVERWRITE_CONTRECORD is found */
XLogRecPtr overwrittenRecPtr;
/* ---------------------------------------- *Decodedrepresentationofcurrentrecord * *UseXLogRecGet*functionstoinvestigatetherecord;thesefields *shouldnotbeaccesseddirectly. *---------------------------------------- *Startandendpointofthelastrecordreadanddecodedby *XLogReadRecord().NextRecPtrisalsousedasthepositiontodecode *next.CallingXLogBeginRead()setsNextRecPtrandEndRecPtrtothe *requestedstartingposition.
*/
XLogRecPtr DecodeRecPtr; /* start of last record decoded */
XLogRecPtr NextRecPtr; /* end+1 of last record decoded */
XLogRecPtr PrevRecPtr; /* start of previous record decoded */
/* Last record returned by XLogReadRecord(). */
DecodedXLogRecord *record;
/* *Bufferfordecodedrecords.Thisisacircularbuffer,though *individualrecordscan'tbesplitinthemiddle,sosomespaceisoften *wastedattheend.Oversizedrecordsthatdon'tfitinthisspaceare *allocatedseparately.
*/ char *decode_buffer;
size_t decode_buffer_size; bool free_decode_buffer; /* need to free? */ char *decode_buffer_head; /* data is read from the head */ char *decode_buffer_tail; /* new data is written at the tail */
/* *Queueofrecordsthathavebeendecoded.Thisisalinkedlistthat *usuallyconsistsofconsecutiverecordsindecode_buffer,butmayalso *containoversizedrecordsallocatedwithpalloc().
*/
DecodedXLogRecord *decode_queue_head; /* oldest decoded record */
DecodedXLogRecord *decode_queue_tail; /* newest decoded record */
/* Get a new XLogReader */ extern XLogReaderState *XLogReaderAllocate(int wal_segment_size, constchar *waldir,
XLogReaderRoutine *routine, void *private_data);
/* Free an XLogReader */ externvoid XLogReaderFree(XLogReaderState *state);
/* Optionally provide a circular decoding buffer to allow readahead. */ externvoid XLogReaderSetDecodeBuffer(XLogReaderState *state, void *buffer,
size_t size);
/* Position the XLogReader to given record */ externvoid XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr); extern XLogRecPtr XLogFindNextRecord(XLogReaderState *state, XLogRecPtr RecPtr);
/* Return values from XLogPageReadCB. */ typedefenum XLogPageReadResult
{
XLREAD_SUCCESS = 0, /* record is successfully read */
XLREAD_FAIL = -1, /* failed during reading a record */
XLREAD_WOULDBLOCK = -2, /* nonblocking mode only, no data */
} XLogPageReadResult;
/* Read the next XLog record. Returns NULL on end-of-WAL or failure */ externstruct XLogRecord *XLogReadRecord(XLogReaderState *state, char **errormsg);
/* Consume the next record or error. */ extern DecodedXLogRecord *XLogNextRecord(XLogReaderState *state, char **errormsg);
/* Release the previously returned record, if necessary. */ extern XLogRecPtr XLogReleasePreviousRecord(XLogReaderState *state);
/* Try to read ahead, if there is data and space. */ extern DecodedXLogRecord *XLogReadAhead(XLogReaderState *state, bool nonblocking);
/* Forget error produced by XLogReaderValidatePageHeader(). */ externvoid XLogReaderResetError(XLogReaderState *state);
/* *ErrorinformationfromWALReadthatbothbackendandfrontendcallercan *process.Currentlyonlyerrorsfrompg_preadcanbereported.
*/ typedefstruct WALReadError
{ int wre_errno; /* errno set by the last pg_pread() */ int wre_off; /* Offset we tried to read from. */ int wre_req; /* Bytes requested to be read. */ int wre_read; /* Bytes read by the last read(). */
WALOpenSegment wre_seg; /* Segment we tried to read from. */
} WALReadError;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.