PostgreSQL Source Code git master
xlogbackup.c File Reference
#include "postgres.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "access/xlogbackup.h"
Include dependency graph for xlogbackup.c:

Go to the source code of this file.

Functions

char * build_backup_content (BackupState *state, bool ishistoryfile)
 

Function Documentation

◆ build_backup_content()

char * build_backup_content ( BackupState state,
bool  ishistoryfile 
)

Definition at line 29 of file xlogbackup.c.

30{
31 char startstrbuf[128];
32 char startxlogfile[MAXFNAMELEN]; /* backup start WAL file */
33 XLogSegNo startsegno;
34 StringInfoData result;
35
36 Assert(state != NULL);
37
38 initStringInfo(&result);
39
40 /* Use the log timezone here, not the session timezone */
41 pg_strftime(startstrbuf, sizeof(startstrbuf), "%Y-%m-%d %H:%M:%S %Z",
42 pg_localtime(&state->starttime, log_timezone));
43
44 XLByteToSeg(state->startpoint, startsegno, wal_segment_size);
45 XLogFileName(startxlogfile, state->starttli, startsegno, wal_segment_size);
46 appendStringInfo(&result, "START WAL LOCATION: %X/%08X (file %s)\n",
47 LSN_FORMAT_ARGS(state->startpoint), startxlogfile);
48
49 if (ishistoryfile)
50 {
51 char stopxlogfile[MAXFNAMELEN]; /* backup stop WAL file */
52 XLogSegNo stopsegno;
53
54 XLByteToSeg(state->stoppoint, stopsegno, wal_segment_size);
55 XLogFileName(stopxlogfile, state->stoptli, stopsegno, wal_segment_size);
56 appendStringInfo(&result, "STOP WAL LOCATION: %X/%08X (file %s)\n",
57 LSN_FORMAT_ARGS(state->stoppoint), stopxlogfile);
58 }
59
60 appendStringInfo(&result, "CHECKPOINT LOCATION: %X/%08X\n",
61 LSN_FORMAT_ARGS(state->checkpointloc));
62 appendStringInfoString(&result, "BACKUP METHOD: streamed\n");
63 appendStringInfo(&result, "BACKUP FROM: %s\n",
64 state->started_in_recovery ? "standby" : "primary");
65 appendStringInfo(&result, "START TIME: %s\n", startstrbuf);
66 appendStringInfo(&result, "LABEL: %s\n", state->name);
67 appendStringInfo(&result, "START TIMELINE: %u\n", state->starttli);
68
69 if (ishistoryfile)
70 {
71 char stopstrfbuf[128];
72
73 /* Use the log timezone here, not the session timezone */
74 pg_strftime(stopstrfbuf, sizeof(stopstrfbuf), "%Y-%m-%d %H:%M:%S %Z",
75 pg_localtime(&state->stoptime, log_timezone));
76
77 appendStringInfo(&result, "STOP TIME: %s\n", stopstrfbuf);
78 appendStringInfo(&result, "STOP TIMELINE: %u\n", state->stoptli);
79 }
80
81 /* either both istartpoint and istarttli should be set, or neither */
82 Assert(XLogRecPtrIsValid(state->istartpoint) == (state->istarttli != 0));
83 if (XLogRecPtrIsValid(state->istartpoint))
84 {
85 appendStringInfo(&result, "INCREMENTAL FROM LSN: %X/%08X\n",
86 LSN_FORMAT_ARGS(state->istartpoint));
87 appendStringInfo(&result, "INCREMENTAL FROM TLI: %u\n",
88 state->istarttli);
89 }
90
91 return result.data;
92}
Assert(PointerIsAligned(start, uint64))
size_t pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
Definition: strftime.c:128
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
Definition: localtime.c:1345
PGDLLIMPORT pg_tz * log_timezone
Definition: pgtz.c:31
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97
Definition: regguts.h:323
int wal_segment_size
Definition: xlog.c:145
#define MAXFNAMELEN
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define XLogRecPtrIsValid(r)
Definition: xlogdefs.h:29
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:47
uint64 XLogSegNo
Definition: xlogdefs.h:52

References appendStringInfo(), appendStringInfoString(), Assert(), StringInfoData::data, initStringInfo(), log_timezone, LSN_FORMAT_ARGS, MAXFNAMELEN, pg_localtime(), pg_strftime(), wal_segment_size, XLByteToSeg, XLogFileName(), and XLogRecPtrIsValid.

Referenced by do_pg_backup_stop(), perform_base_backup(), and pg_backup_stop().