4 * Utilities for replaying WAL records.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/access/xlogutils.h
21 * Prior to 8.4, all activity during recovery was carried out by the startup
22 * process. This local variable continues to be used in many parts of the
23 * code to indicate actions taken by RecoveryManagers. Other processes that
24 * potentially perform work during recovery should check RecoveryInProgress().
25 * See XLogCtl notes in xlog.c.
30 * Like InRecovery, standbyState is only valid in the startup process.
31 * In all other processes it will have the value STANDBY_DISABLED (so
32 * InHotStandby will read as false).
34 * In DISABLED state, we're performing crash recovery or hot standby was
35 * disabled in postgresql.conf.
37 * In INITIALIZED state, we've run InitRecoveryTransactionEnvironment, but
38 * we haven't yet processed a RUNNING_XACTS or shutdown-checkpoint WAL record
39 * to initialize our primary-transaction tracking system.
41 * When the transaction tracking is initialized, we enter the SNAPSHOT_PENDING
42 * state. The tracked information might still be incomplete, so we can't allow
43 * connections yet, but redo functions must update the in-memory state when
46 * In SNAPSHOT_READY mode, we have full knowledge of transactions that are
47 * (or were) running on the primary at the current WAL location. Snapshots
48 * can be taken, and read-only queries can be run.
60 #define InHotStandby (standbyState >= STANDBY_SNAPSHOT_PENDING)
71/* Result codes for XLogReadBufferForRedo[Extended] */
78 * need to be replayed) */
81/* Private data of the read_local_xlog_page_no_wait callback. */
static PgChecksumMode mode
void wal_segment_close(XLogReaderState *state)
void FreeFakeRelcacheEntry(Relation fakerel)
void wal_segment_open(XLogReaderState *state, XLogSegNo nextSegNo, TimeLineID *tli_p)
PGDLLIMPORT bool InRecovery
void XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, uint32 wantLength, TimeLineID currTLI)
@ STANDBY_SNAPSHOT_PENDING
bool XLogHaveInvalidPages(void)
XLogRedoAction XLogReadBufferForRedo(XLogReaderState *record, uint8 block_id, Buffer *buf)
Buffer XLogInitBufferForRedo(XLogReaderState *record, uint8 block_id)
Buffer XLogReadBufferExtended(RelFileLocator rlocator, ForkNumber forknum, BlockNumber blkno, ReadBufferMode mode, Buffer recent_buffer)
void XLogTruncateRelation(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber nblocks)
Relation CreateFakeRelcacheEntry(RelFileLocator rlocator)
int read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page)
PGDLLIMPORT HotStandbyState standbyState
void XLogCheckInvalidPages(void)
void WALReadRaiseError(WALReadError *errinfo)
struct ReadLocalXLogPageNoWaitPrivate ReadLocalXLogPageNoWaitPrivate
void XLogDropRelation(RelFileLocator rlocator, ForkNumber forknum)
int read_local_xlog_page_no_wait(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page)
XLogRedoAction XLogReadBufferForRedoExtended(XLogReaderState *record, uint8 block_id, ReadBufferMode mode, bool get_cleanup_lock, Buffer *buf)
PGDLLIMPORT bool ignore_invalid_pages
void XLogDropDatabase(Oid dbid)