PostgreSQL Source Code  git master
parsexlog.c File Reference
#include "postgres_fe.h"
#include <unistd.h>
#include "access/rmgr.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "access/xlogreader.h"
#include "catalog/pg_control.h"
#include "catalog/storage_xlog.h"
#include "commands/dbcommands_xlog.h"
#include "fe_utils/archive.h"
#include "filemap.h"
#include "pg_rewind.h"
#include "access/rmgrlist.h"
Include dependency graph for parsexlog.c:

Go to the source code of this file.

Macros

#define PG_RMGR(symname, name, redo, desc, identify, startup, cleanup, mask)   name,
 

Functions

static void extractPageInfo (XLogReaderState *record)
 
static bool SimpleXLogPageRead (XLogReaderState *xlogreader, const char *datadir, int *tliIndex, const char *restoreCommand)
 
void extractPageMap (const char *datadir, XLogRecPtr startpoint, int tliIndex, XLogRecPtr endpoint, const char *restoreCommand)
 
XLogRecPtr readOneRecord (const char *datadir, XLogRecPtr ptr, int tliIndex, const char *restoreCommand)
 
void findLastCheckpoint (const char *datadir, XLogRecPtr forkptr, int tliIndex, XLogRecPtr *lastchkptrec, TimeLineID *lastchkpttli, XLogRecPtr *lastchkptredo, const char *restoreCommand)
 

Variables

static const char * RmgrNames [RM_MAX_ID+1]
 
static int xlogreadfd = -1
 
static XLogSegNo xlogreadsegno = -1
 
static char xlogfpath [MAXPGPATH]
 

Macro Definition Documentation

◆ PG_RMGR

#define PG_RMGR (   symname,
  name,
  redo,
  desc,
  identify,
  startup,
  cleanup,
  mask 
)    name,

Definition at line 31 of file parsexlog.c.

Function Documentation

◆ extractPageInfo()

static void extractPageInfo ( XLogReaderState record)
static

Definition at line 371 of file parsexlog.c.

References LSN_FORMAT_ARGS, MAIN_FORKNUM, pg_fatal, process_target_wal_block_change(), XLogReaderState::ReadRecPtr, RmgrNames, XLOG_DBASE_CREATE, XLOG_DBASE_DROP, XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_OPMASK, XLogRecGetBlockTag(), XLogRecGetInfo, XLogRecGetRmid, XLogRecMaxBlockId, XLR_INFO_MASK, and XLR_SPECIAL_REL_UPDATE.

Referenced by extractPageMap().

372 {
373  int block_id;
374  RmgrId rmid = XLogRecGetRmid(record);
375  uint8 info = XLogRecGetInfo(record);
376  uint8 rminfo = info & ~XLR_INFO_MASK;
377 
378  /* Is this a special record type that I recognize? */
379 
380  if (rmid == RM_DBASE_ID && rminfo == XLOG_DBASE_CREATE)
381  {
382  /*
383  * New databases can be safely ignored. It won't be present in the
384  * source system, so it will be deleted. There's one corner-case,
385  * though: if a new, different, database is also created in the source
386  * system, we'll see that the files already exist and not copy them.
387  * That's OK, though; WAL replay of creating the new database, from
388  * the source systems's WAL, will re-copy the new database,
389  * overwriting the database created in the target system.
390  */
391  }
392  else if (rmid == RM_DBASE_ID && rminfo == XLOG_DBASE_DROP)
393  {
394  /*
395  * An existing database was dropped. We'll see that the files don't
396  * exist in the target data dir, and copy them in toto from the source
397  * system. No need to do anything special here.
398  */
399  }
400  else if (rmid == RM_SMGR_ID && rminfo == XLOG_SMGR_CREATE)
401  {
402  /*
403  * We can safely ignore these. The file will be removed from the
404  * target, if it doesn't exist in source system. If a file with same
405  * name is created in source system, too, there will be WAL records
406  * for all the blocks in it.
407  */
408  }
409  else if (rmid == RM_SMGR_ID && rminfo == XLOG_SMGR_TRUNCATE)
410  {
411  /*
412  * We can safely ignore these. When we compare the sizes later on,
413  * we'll notice that they differ, and copy the missing tail from
414  * source system.
415  */
416  }
417  else if (rmid == RM_XACT_ID &&
418  ((rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_COMMIT ||
419  (rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_COMMIT_PREPARED ||
420  (rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_ABORT ||
421  (rminfo & XLOG_XACT_OPMASK) == XLOG_XACT_ABORT_PREPARED))
422  {
423  /*
424  * These records can include "dropped rels". We can safely ignore
425  * them, we will see that they are missing and copy them from the
426  * source.
427  */
428  }
429  else if (info & XLR_SPECIAL_REL_UPDATE)
430  {
431  /*
432  * This record type modifies a relation file in some special way, but
433  * we don't recognize the type. That's bad - we don't know how to
434  * track that change.
435  */
436  pg_fatal("WAL record modifies a relation, but record type is not recognized: "
437  "lsn: %X/%X, rmgr: %s, info: %02X",
438  LSN_FORMAT_ARGS(record->ReadRecPtr),
439  RmgrNames[rmid], info);
440  }
441 
442  for (block_id = 0; block_id <= XLogRecMaxBlockId(record); block_id++)
443  {
444  RelFileNode rnode;
445  ForkNumber forknum;
446  BlockNumber blkno;
447 
448  if (!XLogRecGetBlockTag(record, block_id, &rnode, &forknum, &blkno))
449  continue;
450 
451  /* We only care about the main fork; others are copied in toto */
452  if (forknum != MAIN_FORKNUM)
453  continue;
454 
455  process_target_wal_block_change(forknum, rnode, blkno);
456  }
457 }
#define XLOG_XACT_COMMIT
Definition: xact.h:148
#define XLR_SPECIAL_REL_UPDATE
Definition: xlogrecord.h:71
unsigned char uint8
Definition: c.h:439
#define pg_fatal(...)
Definition: pg_rewind.h:37
static const char * RmgrNames[RM_MAX_ID+1]
Definition: parsexlog.c:34
uint32 BlockNumber
Definition: block.h:31
#define XLOG_SMGR_CREATE
Definition: storage_xlog.h:30
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLOG_DBASE_DROP
#define XLOG_XACT_ABORT_PREPARED
Definition: xact.h:152
XLogRecPtr ReadRecPtr
Definition: xlogreader.h:178
void process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
Definition: filemap.c:292
#define XLogRecMaxBlockId(decoder)
Definition: xlogreader.h:385
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:377
ForkNumber
Definition: relpath.h:40
#define XLOG_SMGR_TRUNCATE
Definition: storage_xlog.h:31
bool XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum)
Definition: xlogreader.c:2132
uint8 RmgrId
Definition: rmgr.h:11
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_XACT_ABORT
Definition: xact.h:150
#define XLOG_XACT_OPMASK
Definition: xact.h:158
#define XLOG_DBASE_CREATE
#define XLOG_XACT_COMMIT_PREPARED
Definition: xact.h:151
#define XLogRecGetRmid(decoder)
Definition: xlogreader.h:378

◆ extractPageMap()

void extractPageMap ( const char *  datadir,
XLogRecPtr  startpoint,
int  tliIndex,
XLogRecPtr  endpoint,
const char *  restoreCommand 
)

Definition at line 57 of file parsexlog.c.

References Assert, close, XLogReaderState::EndRecPtr, extractPageInfo(), LSN_FORMAT_ARGS, pg_fatal, SimpleXLogPageRead(), WalSegSz, XLogBeginRead(), xlogreader, XLogReaderAllocate(), XLogReaderFree(), xlogreadfd, XLogReadRecord(), and XLREAD_NEED_DATA.

Referenced by main().

59 {
60  XLogRecord *record;
62  char *errormsg;
63 
64  xlogreader = XLogReaderAllocate(WalSegSz, datadir, NULL);
65 
66  if (xlogreader == NULL)
67  pg_fatal("out of memory");
68 
69  XLogBeginRead(xlogreader, startpoint);
70  do
71  {
72  while (XLogReadRecord(xlogreader, &record, &errormsg) ==
74  {
75  if (!SimpleXLogPageRead(xlogreader, datadir,
76  &tliIndex, restoreCommand))
77  break;
78  }
79 
80  if (record == NULL)
81  {
82  XLogRecPtr errptr = xlogreader->EndRecPtr;
83 
84  if (errormsg)
85  pg_fatal("could not read WAL record at %X/%X: %s",
86  LSN_FORMAT_ARGS(errptr),
87  errormsg);
88  else
89  pg_fatal("could not read WAL record at %X/%X",
90  LSN_FORMAT_ARGS(errptr));
91  }
92 
93  extractPageInfo(xlogreader);
94 
95  } while (xlogreader->EndRecPtr < endpoint);
96 
97  /*
98  * If 'endpoint' didn't point exactly at a record boundary, the caller
99  * messed up.
100  */
101  Assert(xlogreader->EndRecPtr == endpoint);
102 
103  XLogReaderFree(xlogreader);
104  if (xlogreadfd != -1)
105  {
106  close(xlogreadfd);
107  xlogreadfd = -1;
108  }
109 }
static bool SimpleXLogPageRead(XLogReaderState *xlogreader, const char *datadir, int *tliIndex, const char *restoreCommand)
Definition: parsexlog.c:247
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, WALSegmentCleanupCB cleanup_cb)
Definition: xlogreader.c:82
#define pg_fatal(...)
Definition: pg_rewind.h:37
XLogReadRecordResult XLogReadRecord(XLogReaderState *state, XLogRecord **record, char **errormsg)
Definition: xlogreader.c:346
XLogRecPtr EndRecPtr
Definition: xlogreader.h:179
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
char * datadir
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
Definition: xlogreader.c:252
static XLogReaderState * xlogreader
Definition: walsender.c:137
void XLogReaderFree(XLogReaderState *state)
Definition: xlogreader.c:142
static int xlogreadfd
Definition: parsexlog.c:40
static void extractPageInfo(XLogReaderState *record)
Definition: parsexlog.c:371
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:804
uint32 WalSegSz
Definition: streamutil.c:34
#define close(a)
Definition: win32.h:12

◆ findLastCheckpoint()

void findLastCheckpoint ( const char *  datadir,
XLogRecPtr  forkptr,
int  tliIndex,
XLogRecPtr lastchkptrec,
TimeLineID lastchkpttli,
XLogRecPtr lastchkptredo,
const char *  restoreCommand 
)

Definition at line 160 of file parsexlog.c.

References close, LSN_FORMAT_ARGS, pg_fatal, CheckPoint::redo, SimpleXLogPageRead(), SizeOfXLogLongPHD, SizeOfXLogShortPHD, CheckPoint::ThisTimeLineID, WalSegSz, XLogRecord::xl_prev, XLOG_CHECKPOINT_ONLINE, XLOG_CHECKPOINT_SHUTDOWN, XLogBeginRead(), xlogreader, XLogReaderAllocate(), XLogReaderFree(), xlogreadfd, XLogReadRecord(), XLogRecGetData, XLogRecGetInfo, XLogRecGetRmid, XLogSegmentOffset, XLR_INFO_MASK, and XLREAD_NEED_DATA.

Referenced by main().

163 {
164  /* Walk backwards, starting from the given record */
165  XLogRecord *record;
166  XLogRecPtr searchptr;
168  char *errormsg;
169 
170  /*
171  * The given fork pointer points to the end of the last common record,
172  * which is not necessarily the beginning of the next record, if the
173  * previous record happens to end at a page boundary. Skip over the page
174  * header in that case to find the next record.
175  */
176  if (forkptr % XLOG_BLCKSZ == 0)
177  {
178  if (XLogSegmentOffset(forkptr, WalSegSz) == 0)
179  forkptr += SizeOfXLogLongPHD;
180  else
181  forkptr += SizeOfXLogShortPHD;
182  }
183 
184  xlogreader = XLogReaderAllocate(WalSegSz, datadir, NULL);
185  if (xlogreader == NULL)
186  pg_fatal("out of memory");
187 
188  searchptr = forkptr;
189  for (;;)
190  {
191  uint8 info;
192 
193  XLogBeginRead(xlogreader, searchptr);
194  while (XLogReadRecord(xlogreader, &record, &errormsg) ==
196  {
197  if (!SimpleXLogPageRead(xlogreader, datadir,
198  &tliIndex, restoreCommand))
199  break;
200  }
201 
202  if (record == NULL)
203  {
204  if (errormsg)
205  pg_fatal("could not find previous WAL record at %X/%X: %s",
206  LSN_FORMAT_ARGS(searchptr),
207  errormsg);
208  else
209  pg_fatal("could not find previous WAL record at %X/%X",
210  LSN_FORMAT_ARGS(searchptr));
211  }
212 
213  /*
214  * Check if it is a checkpoint record. This checkpoint record needs to
215  * be the latest checkpoint before WAL forked and not the checkpoint
216  * where the primary has been stopped to be rewound.
217  */
218  info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
219  if (searchptr < forkptr &&
220  XLogRecGetRmid(xlogreader) == RM_XLOG_ID &&
221  (info == XLOG_CHECKPOINT_SHUTDOWN ||
222  info == XLOG_CHECKPOINT_ONLINE))
223  {
224  CheckPoint checkPoint;
225 
226  memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
227  *lastchkptrec = searchptr;
228  *lastchkpttli = checkPoint.ThisTimeLineID;
229  *lastchkptredo = checkPoint.redo;
230  break;
231  }
232 
233  /* Walk backwards to previous record. */
234  searchptr = record->xl_prev;
235  }
236 
237  XLogReaderFree(xlogreader);
238  if (xlogreadfd != -1)
239  {
240  close(xlogreadfd);
241  xlogreadfd = -1;
242  }
243 }
static bool SimpleXLogPageRead(XLogReaderState *xlogreader, const char *datadir, int *tliIndex, const char *restoreCommand)
Definition: parsexlog.c:247
XLogRecPtr xl_prev
Definition: xlogrecord.h:45
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, WALSegmentCleanupCB cleanup_cb)
Definition: xlogreader.c:82
#define XLOG_CHECKPOINT_ONLINE
Definition: pg_control.h:68
unsigned char uint8
Definition: c.h:439
#define pg_fatal(...)
Definition: pg_rewind.h:37
XLogReadRecordResult XLogReadRecord(XLogReaderState *state, XLogRecord **record, char **errormsg)
Definition: xlogreader.c:346
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLogRecGetData(decoder)
Definition: xlogreader.h:382
#define XLOG_CHECKPOINT_SHUTDOWN
Definition: pg_control.h:67
char * datadir
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
Definition: xlogreader.c:252
static XLogReaderState * xlogreader
Definition: walsender.c:137
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:377
void XLogReaderFree(XLogReaderState *state)
Definition: xlogreader.c:142
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
static int xlogreadfd
Definition: parsexlog.c:40
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define SizeOfXLogShortPHD
Definition: xlog_internal.h:52
uint32 WalSegSz
Definition: streamutil.c:34
TimeLineID ThisTimeLineID
Definition: pg_control.h:39
#define close(a)
Definition: win32.h:12
XLogRecPtr redo
Definition: pg_control.h:37
#define XLogRecGetRmid(decoder)
Definition: xlogreader.h:378
#define SizeOfXLogLongPHD
Definition: xlog_internal.h:69

◆ readOneRecord()

XLogRecPtr readOneRecord ( const char *  datadir,
XLogRecPtr  ptr,
int  tliIndex,
const char *  restoreCommand 
)

Definition at line 116 of file parsexlog.c.

References close, XLogReaderState::EndRecPtr, LSN_FORMAT_ARGS, pg_fatal, SimpleXLogPageRead(), WalSegSz, XLogBeginRead(), xlogreader, XLogReaderAllocate(), XLogReaderFree(), xlogreadfd, XLogReadRecord(), and XLREAD_NEED_DATA.

Referenced by main().

118 {
119  XLogRecord *record;
121  char *errormsg;
122  XLogRecPtr endptr;
123 
124  xlogreader = XLogReaderAllocate(WalSegSz, datadir, NULL);
125  if (xlogreader == NULL)
126  pg_fatal("out of memory");
127 
128  XLogBeginRead(xlogreader, ptr);
129  while (XLogReadRecord(xlogreader, &record, &errormsg) ==
131  {
132  if (!SimpleXLogPageRead(xlogreader, datadir, &tliIndex, restoreCommand))
133  break;
134  }
135  if (record == NULL)
136  {
137  if (errormsg)
138  pg_fatal("could not read WAL record at %X/%X: %s",
139  LSN_FORMAT_ARGS(ptr), errormsg);
140  else
141  pg_fatal("could not read WAL record at %X/%X",
142  LSN_FORMAT_ARGS(ptr));
143  }
144  endptr = xlogreader->EndRecPtr;
145 
146  XLogReaderFree(xlogreader);
147  if (xlogreadfd != -1)
148  {
149  close(xlogreadfd);
150  xlogreadfd = -1;
151  }
152 
153  return endptr;
154 }
static bool SimpleXLogPageRead(XLogReaderState *xlogreader, const char *datadir, int *tliIndex, const char *restoreCommand)
Definition: parsexlog.c:247
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, WALSegmentCleanupCB cleanup_cb)
Definition: xlogreader.c:82
#define pg_fatal(...)
Definition: pg_rewind.h:37
XLogReadRecordResult XLogReadRecord(XLogReaderState *state, XLogRecord **record, char **errormsg)
Definition: xlogreader.c:346
XLogRecPtr EndRecPtr
Definition: xlogreader.h:179
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
char * datadir
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
Definition: xlogreader.c:252
static XLogReaderState * xlogreader
Definition: walsender.c:137
void XLogReaderFree(XLogReaderState *state)
Definition: xlogreader.c:142
static int xlogreadfd
Definition: parsexlog.c:40
uint64 XLogRecPtr
Definition: xlogdefs.h:21
uint32 WalSegSz
Definition: streamutil.c:34
#define close(a)
Definition: win32.h:12

◆ SimpleXLogPageRead()

static bool SimpleXLogPageRead ( XLogReaderState xlogreader,
const char *  datadir,
int *  tliIndex,
const char *  restoreCommand 
)
static

Definition at line 247 of file parsexlog.c.

References Assert, close, MAXFNAMELEN, MAXPGPATH, PG_BINARY, pg_log_debug, pg_log_error, read, XLogReaderState::readBuf, XLogReaderState::readPagePtr, XLogReaderState::reqLen, RestoreArchivedFile(), XLogReaderState::seg, XLogReaderState::segcxt, snprintf, targetHistory, targetNentries, TimeLineHistoryEntry::tli, WalSegSz, WALSegmentContext::ws_dir, WALOpenSegment::ws_tli, XLByteInSeg, XLByteToSeg, XLOGDIR, XLogFileName, xlogfpath, XLogReaderSetInputData(), xlogreadfd, xlogreadsegno, XLogSegmentOffset, and XLogSegNoOffsetToRecPtr.

Referenced by extractPageMap(), findLastCheckpoint(), and readOneRecord().

249 {
250  XLogRecPtr targetPagePtr = xlogreader->readPagePtr;
251  char *readBuf = xlogreader->readBuf;
252  uint32 targetPageOff;
253  XLogRecPtr targetSegEnd;
254  XLogSegNo targetSegNo;
255  int r;
256 
257  Assert(xlogreader->reqLen <= XLOG_BLCKSZ);
258 
259  XLByteToSeg(targetPagePtr, targetSegNo, WalSegSz);
260  XLogSegNoOffsetToRecPtr(targetSegNo + 1, 0, WalSegSz, targetSegEnd);
261  targetPageOff = XLogSegmentOffset(targetPagePtr, WalSegSz);
262 
263  /*
264  * See if we need to switch to a new segment because the requested record
265  * is not in the currently open one.
266  */
267  if (xlogreadfd >= 0 &&
268  !XLByteInSeg(targetPagePtr, xlogreadsegno, WalSegSz))
269  {
270  close(xlogreadfd);
271  xlogreadfd = -1;
272  }
273 
274  XLByteToSeg(targetPagePtr, xlogreadsegno, WalSegSz);
275 
276  if (xlogreadfd < 0)
277  {
278  char xlogfname[MAXFNAMELEN];
279 
280  /*
281  * Since incomplete segments are copied into next timelines, switch to
282  * the timeline holding the required segment. Assuming this scan can
283  * be done both forward and backward, consider also switching timeline
284  * accordingly.
285  */
286  while (*tliIndex < targetNentries - 1 &&
287  targetHistory[*tliIndex].end < targetSegEnd)
288  (*tliIndex)++;
289  while (*tliIndex > 0 &&
290  targetHistory[*tliIndex].begin >= targetSegEnd)
291  (*tliIndex)--;
292 
293  XLogFileName(xlogfname, targetHistory[*tliIndex].tli,
295 
296  snprintf(xlogfpath, MAXPGPATH, "%s/" XLOGDIR "/%s",
297  xlogreader->segcxt.ws_dir, xlogfname);
298 
299  xlogreadfd = open(xlogfpath, O_RDONLY | PG_BINARY, 0);
300 
301  if (xlogreadfd < 0)
302  {
303  /*
304  * If we have no restore_command to execute, then exit.
305  */
306  if (restoreCommand == NULL)
307  {
308  pg_log_error("could not open file \"%s\": %m", xlogfpath);
309  XLogReaderSetInputData(xlogreader, -1);
310  return false;
311  }
312 
313  /*
314  * Since we have restore_command, then try to retrieve missing WAL
315  * file from the archive.
316  */
318  xlogfname,
319  WalSegSz,
320  restoreCommand);
321 
322  if (xlogreadfd < 0)
323  {
324  XLogReaderSetInputData(xlogreader, -1);
325  return false;
326  }
327  else
328  pg_log_debug("using file \"%s\" restored from archive",
329  xlogfpath);
330  }
331  }
332 
333  /*
334  * At this point, we have the right segment open.
335  */
336  Assert(xlogreadfd != -1);
337 
338  /* Read the requested page */
339  if (lseek(xlogreadfd, (off_t) targetPageOff, SEEK_SET) < 0)
340  {
341  pg_log_error("could not seek in file \"%s\": %m", xlogfpath);
342  XLogReaderSetInputData(xlogreader, -1);
343  return false;
344  }
345 
346 
347  r = read(xlogreadfd, readBuf, XLOG_BLCKSZ);
348  if (r != XLOG_BLCKSZ)
349  {
350  if (r < 0)
351  pg_log_error("could not read file \"%s\": %m", xlogfpath);
352  else
353  pg_log_error("could not read file \"%s\": read %d of %zu",
354  xlogfpath, r, (Size) XLOG_BLCKSZ);
355 
356  XLogReaderSetInputData(xlogreader, -1);
357  return false;
358  }
359 
360  Assert(targetSegNo == xlogreadsegno);
361 
362  xlogreader->seg.ws_tli = targetHistory[*tliIndex].tli;
363  XLogReaderSetInputData(xlogreader, XLOG_BLCKSZ);
364  return true;
365 }
char ws_dir[MAXPGPATH]
Definition: xlogreader.h:55
TimeLineHistoryEntry * targetHistory
Definition: pg_rewind.c:71
#define pg_log_error(...)
Definition: logging.h:80
bool RestoreArchivedFile(char *path, const char *xlogfname, const char *recovername, off_t expectedSize, bool cleanupEnabled)
Definition: xlogarchive.c:53
TimeLineID tli
Definition: timeline.h:27
#define PG_BINARY
Definition: c.h:1271
#define XLByteInSeg(xlrp, logSegNo, wal_segsz_bytes)
WALOpenSegment seg
Definition: xlogreader.h:243
#define pg_log_debug(...)
Definition: logging.h:92
#define MAXPGPATH
XLogRecPtr readPagePtr
Definition: xlogreader.h:187
uint64 XLogSegNo
Definition: xlogdefs.h:48
unsigned int uint32
Definition: c.h:441
#define MAXFNAMELEN
#define XLOGDIR
int targetNentries
Definition: pg_rewind.c:72
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
static int xlogreadfd
Definition: parsexlog.c:40
static XLogSegNo xlogreadsegno
Definition: parsexlog.c:41
static char xlogfpath[MAXPGPATH]
Definition: parsexlog.c:42
#define XLogSegNoOffsetToRecPtr(segno, offset, wal_segsz_bytes, dest)
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:804
size_t Size
Definition: c.h:540
#define XLogFileName(fname, tli, logSegNo, wal_segsz_bytes)
TimeLineID ws_tli
Definition: xlogreader.h:49
uint32 WalSegSz
Definition: streamutil.c:34
WALSegmentContext segcxt
Definition: xlogreader.h:242
#define close(a)
Definition: win32.h:12
#define snprintf
Definition: port.h:216
static void XLogReaderSetInputData(XLogReaderState *state, int32 len)
Definition: xlogreader.h:304
#define read(a, b, c)
Definition: win32.h:13
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)

Variable Documentation

◆ RmgrNames

const char* RmgrNames[RM_MAX_ID+1]
static

Definition at line 34 of file parsexlog.c.

Referenced by extractPageInfo().

◆ xlogfpath

char xlogfpath[MAXPGPATH]
static

Definition at line 42 of file parsexlog.c.

Referenced by KeepFileRestoredFromArchive(), and SimpleXLogPageRead().

◆ xlogreadfd

int xlogreadfd = -1
static

Definition at line 40 of file parsexlog.c.

Referenced by extractPageMap(), findLastCheckpoint(), readOneRecord(), and SimpleXLogPageRead().

◆ xlogreadsegno

XLogSegNo xlogreadsegno = -1
static

Definition at line 41 of file parsexlog.c.

Referenced by SimpleXLogPageRead().