1/*-------------------------------------------------------------------------
4 * timeline-related functions.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 *-------------------------------------------------------------------------
16 * This is copy-pasted from the backend readTimeLineHistory, modified to
17 * return a malloc'd array and to work without backend functions.
20 * Try to read a timeline's history file.
22 * If successful, return the list of component TLIs (the given TLI followed by
23 * its ancestor TLIs). If we can't find the history file, assume that the
24 * timeline has no parents, and return a list of just the specified timeline
37 bool lastline =
false;
53 while (*bufptr && *bufptr !=
'\n')
60 /* skip leading whitespace and check for # comment */
61 for (ptr = fline; *ptr; ptr++)
63 if (!isspace((
unsigned char) *ptr))
66 if (*ptr ==
'0円' || *ptr ==
'#')
69 nfields = sscanf(fline,
"%u\t%X/%08X", &tli, &switchpoint_hi, &switchpoint_lo);
73 /* expect a numeric timeline ID as first field of line */
84 if (entries && tli <= lasttli)
96 entry = &entries[nlines - 1];
98 entry->
begin = prevend;
99 entry->
end = ((
uint64) (switchpoint_hi)) << 32 | (
uint64) switchpoint_lo;
100 prevend = entry->
end;
102 /* we ignore the remainder of each line */
105 if (entries && targetTLI <= lasttli)
113 * Create one more entry for the "tip" of the timeline, which has no entry
114 * in the history file.
122 entry = &entries[nlines - 1];
123 entry->
tli = targetTLI;
124 entry->
begin = prevend;
TimeLineHistoryEntry * rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
void * pg_malloc(size_t size)
void * pg_realloc(void *ptr, size_t size)
#define pg_log_error(...)
#define pg_log_error_detail(...)
#define InvalidXLogRecPtr