PostgreSQL Source Code  git master
xlogbackup.h File Reference
#include "access/xlogdefs.h"
#include "pgtime.h"
Include dependency graph for xlogbackup.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BackupState
 

Typedefs

typedef struct BackupState BackupState
 

Functions

char * build_backup_content (BackupState *state, bool ishistoryfile)
 

Typedef Documentation

◆ BackupState

typedef struct BackupState BackupState

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  StringInfo result = makeStringInfo();
35  char *data;
36 
37  Assert(state != NULL);
38 
39  /* Use the log timezone here, not the session timezone */
40  pg_strftime(startstrbuf, sizeof(startstrbuf), "%Y-%m-%d %H:%M:%S %Z",
41  pg_localtime(&state->starttime, log_timezone));
42 
43  XLByteToSeg(state->startpoint, startsegno, wal_segment_size);
44  XLogFileName(startxlogfile, state->starttli, startsegno, wal_segment_size);
45  appendStringInfo(result, "START WAL LOCATION: %X/%X (file %s)\n",
46  LSN_FORMAT_ARGS(state->startpoint), startxlogfile);
47 
48  if (ishistoryfile)
49  {
50  char stopxlogfile[MAXFNAMELEN]; /* backup stop WAL file */
51  XLogSegNo stopsegno;
52 
53  XLByteToSeg(state->stoppoint, stopsegno, wal_segment_size);
54  XLogFileName(stopxlogfile, state->stoptli, stopsegno, wal_segment_size);
55  appendStringInfo(result, "STOP WAL LOCATION: %X/%X (file %s)\n",
56  LSN_FORMAT_ARGS(state->stoppoint), stopxlogfile);
57  }
58 
59  appendStringInfo(result, "CHECKPOINT LOCATION: %X/%X\n",
60  LSN_FORMAT_ARGS(state->checkpointloc));
61  appendStringInfo(result, "BACKUP METHOD: streamed\n");
62  appendStringInfo(result, "BACKUP FROM: %s\n",
63  state->started_in_recovery ? "standby" : "primary");
64  appendStringInfo(result, "START TIME: %s\n", startstrbuf);
65  appendStringInfo(result, "LABEL: %s\n", state->name);
66  appendStringInfo(result, "START TIMELINE: %u\n", state->starttli);
67 
68  if (ishistoryfile)
69  {
70  char stopstrfbuf[128];
71 
72  /* Use the log timezone here, not the session timezone */
73  pg_strftime(stopstrfbuf, sizeof(stopstrfbuf), "%Y-%m-%d %H:%M:%S %Z",
74  pg_localtime(&state->stoptime, log_timezone));
75 
76  appendStringInfo(result, "STOP TIME: %s\n", stopstrfbuf);
77  appendStringInfo(result, "STOP TIMELINE: %u\n", state->stoptli);
78  }
79 
80  data = result->data;
81  pfree(result);
82 
83  return data;
84 }
Assert(fmt[strlen(fmt) - 1] !='\n')
void pfree(void *pointer)
Definition: mcxt.c:1456
const void * data
struct pg_tm * pg_localtime(const pg_time_t *timep, const pg_tz *tz)
Definition: localtime.c:1344
size_t pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
Definition: strftime.c:128
PGDLLIMPORT pg_tz * log_timezone
Definition: pgtz.c:31
StringInfo makeStringInfo(void)
Definition: stringinfo.c:41
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
Definition: regguts.h:323
int wal_segment_size
Definition: xlog.c:146
#define MAXFNAMELEN
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
uint64 XLogSegNo
Definition: xlogdefs.h:48

References appendStringInfo(), Assert(), StringInfoData::data, data, log_timezone, LSN_FORMAT_ARGS, makeStringInfo(), MAXFNAMELEN, pfree(), pg_localtime(), pg_strftime(), wal_segment_size, XLByteToSeg, and XLogFileName().

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