31 #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
38 #define RmgrName(rmid) (((rmid) <= RM_MAX_BUILTIN_ID) ? \
39 RmgrNames[rmid] : "custom")
55 int reqLen,
XLogRecPtr targetRecPtr,
char *readBuf);
67 XLogRecPtr endpoint,
const char *restoreCommand)
75 private.restoreCommand = restoreCommand;
80 pg_fatal(
"out of memory while allocating a WAL reading processor");
92 pg_fatal(
"could not read WAL record at %X/%X: %s",
96 pg_fatal(
"could not read WAL record at %X/%X",
108 pg_fatal(
"end pointer %X/%X is not a valid end point; expected %X/%X",
125 const char *restoreCommand)
134 private.restoreCommand = restoreCommand;
139 pg_fatal(
"out of memory while allocating a WAL reading processor");
146 pg_fatal(
"could not read WAL record at %X/%X: %s",
149 pg_fatal(
"could not read WAL record at %X/%X",
170 XLogRecPtr *lastchkptredo,
const char *restoreCommand)
187 if (forkptr % XLOG_BLCKSZ == 0)
195 private.tliIndex = tliIndex;
196 private.restoreCommand = restoreCommand;
201 pg_fatal(
"out of memory while allocating a WAL reading processor");
214 pg_fatal(
"could not find previous WAL record at %X/%X: %s",
218 pg_fatal(
"could not find previous WAL record at %X/%X",
235 current_tli, current_segno,
WalSegSz);
247 if (searchptr < forkptr &&
255 *lastchkptrec = searchptr;
257 *lastchkptredo = checkPoint.
redo;
276 int reqLen,
XLogRecPtr targetRecPtr,
char *readBuf)
314 while (private->tliIndex > 0 &&
331 if (private->restoreCommand == NULL)
344 private->restoreCommand);
360 if (lseek(
xlogreadfd, (off_t) targetPageOff, SEEK_SET) < 0)
368 if (r != XLOG_BLCKSZ)
373 pg_log_error(
"could not read file \"%s\": read %d of %zu",
442 else if (rmid == RM_XACT_ID &&
461 pg_fatal(
"WAL record modifies a relation, but record type is not recognized: "
462 "lsn: %X/%X, rmid: %d, rmgr: %s, info: %02X",
474 &rlocator, &forknum, &blkno, NULL))
#define Assert(condition)
#define XLOG_DBASE_CREATE_WAL_LOG
#define XLOG_DBASE_CREATE_FILE_COPY
void process_target_wal_block_change(ForkNumber forknum, RelFileLocator rlocator, BlockNumber blkno)
void keepwal_add_entry(const char *path)
#define pg_log_error(...)
#define pg_log_debug(...)
static int SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *readBuf)
struct XLogPageReadPrivate XLogPageReadPrivate
static XLogSegNo xlogreadsegno
void extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex, XLogRecPtr endpoint, const char *restoreCommand)
static const char *const RmgrNames[RM_MAX_ID+1]
static void extractPageInfo(XLogReaderState *record)
void findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex, XLogRecPtr *lastchkptrec, TimeLineID *lastchkpttli, XLogRecPtr *lastchkptredo, const char *restoreCommand)
XLogRecPtr readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex, const char *restoreCommand)
static char xlogfpath[MAXPGPATH]
#define XLOG_CHECKPOINT_SHUTDOWN
#define XLOG_CHECKPOINT_ONLINE
TimeLineHistoryEntry * targetHistory
#define XLOG_SMGR_TRUNCATE
TimeLineID ThisTimeLineID
#define XLOG_XACT_COMMIT_PREPARED
#define XLOG_XACT_ABORT_PREPARED
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
#define XLogSegNoOffsetToRecPtr(segno, offset, wal_segsz_bytes, dest)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
#define SizeOfXLogShortPHD
#define SizeOfXLogLongPHD
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define XLByteInSeg(xlrp, logSegNo, wal_segsz_bytes)
bool RestoreArchivedFile(char *path, const char *xlogfname, const char *recovername, off_t expectedSize, bool cleanupEnabled)
#define LSN_FORMAT_ARGS(lsn)
bool XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum, Buffer *prefetch_buffer)
XLogRecord * XLogReadRecord(XLogReaderState *state, char **errormsg)
void XLogReaderFree(XLogReaderState *state)
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, XLogReaderRoutine *routine, void *private_data)
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
#define XLogRecGetInfo(decoder)
#define XLogRecGetRmid(decoder)
#define XLogRecGetData(decoder)
#define XLogRecMaxBlockId(decoder)
#define XLR_SPECIAL_REL_UPDATE
static XLogReaderState * xlogreader