timeline.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * timeline.h
  3. *
  4. * Functions for reading and writing timeline history files.
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/access/timeline.h
  10. */
  11. #ifndef TIMELINE_H
  12. #define TIMELINE_H
  13. #include "access/xlogdefs.h"
  14. #include "nodes/pg_list.h"
  15. /*
  16. * A list of these structs describes the timeline history of the server. Each
  17. * TimeLineHistoryEntry represents a piece of WAL belonging to the history,
  18. * from newest to oldest. All WAL locations between 'begin' and 'end' belong to
  19. * the timeline represented by the entry. Together the 'begin' and 'end'
  20. * pointers of all the entries form a contiguous line from beginning of time
  21. * to infinity.
  22. */
  23. typedef struct
  24. {
  25. TimeLineID tli;
  26. XLogRecPtr begin; /* inclusive */
  27. XLogRecPtr end; /* exclusive, InvalidXLogRecPtr means infinity */
  28. } TimeLineHistoryEntry;
  29. extern List *readTimeLineHistory(TimeLineID targetTLI);
  30. extern bool existsTimeLineHistory(TimeLineID probeTLI);
  31. extern TimeLineID findNewestTimeLine(TimeLineID startTLI);
  32. extern void writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
  33. XLogRecPtr switchpoint, char *reason);
  34. extern void writeTimeLineHistoryFile(TimeLineID tli, char *content, int size);
  35. extern void restoreTimeLineHistoryFiles(TimeLineID begin, TimeLineID end);
  36. extern bool tliInHistory(TimeLineID tli, List *expectedTLEs);
  37. extern TimeLineID tliOfPointInHistory(XLogRecPtr ptr, List *history);
  38. extern XLogRecPtr tliSwitchPoint(TimeLineID tli, List *history,
  39. TimeLineID *nextTLI);
  40. #endif /* TIMELINE_H */