This was used as the returned result type of the generated contents for
the backup_label and backup history files. This is replaced by a simple
string, reducing the cleanup burden of all the callers of
build_backup_content().
Reviewed-by: Bharath Rupireddy
Discussion: https://postgr.es/m/
[email protected]
}
else
{
- StringInfo history_file;
+ char *history_file;
/*
* Write the backup-end xlog record
/* Build and save the contents of the backup history file */
history_file = build_backup_content(state, true);
- fprintf(fp, "%s", history_file->data);
- pfree(history_file->data);
+ fprintf(fp, "%s", history_file);
pfree(history_file);
if (fflush(fp) || ferror(fp) || FreeFile(fp))
* When ishistoryfile is true, it creates the contents for a backup history
* file, otherwise it creates contents for a backup_label file.
*
- * Returns the result generated as a palloc'd StringInfo.
+ * Returns the result generated as a palloc'd string.
*/
-StringInfo
+char *
build_backup_content(BackupState *state, bool ishistoryfile)
{
char startstrbuf[128];
char startxlogfile[MAXFNAMELEN]; /* backup start WAL file */
XLogSegNo startsegno;
StringInfo result = makeStringInfo();
+ char *data;
Assert(state != NULL);
appendStringInfo(result, "STOP TIMELINE: %u\n", state->stoptli);
}
- return result;
+ data = result->data;
+ pfree(result);
+
+ return data;
}
Datum values[PG_BACKUP_STOP_V2_COLS] = {0};
bool nulls[PG_BACKUP_STOP_V2_COLS] = {0};
bool waitforarchive = PG_GETARG_BOOL(0);
- StringInfo backup_label;
+ char *backup_label;
SessionBackupState status = get_backup_status();
/* Initialize attributes information in the tuple descriptor */
backup_label = build_backup_content(backup_state, false);
values[0] = LSNGetDatum(backup_state->stoppoint);
- values[1] = CStringGetTextDatum(backup_label->data);
+ values[1] = CStringGetTextDatum(backup_label);
values[2] = CStringGetTextDatum(tablespace_map->data);
/* Deallocate backup-related variables */
pfree(tablespace_map->data);
pfree(tablespace_map);
tablespace_map = NULL;
- pfree(backup_label->data);
pfree(backup_label);
/* Returns the record as Datum */
{
struct stat statbuf;
bool sendtblspclinks = true;
- StringInfo backup_label;
+ char *backup_label;
bbsink_begin_archive(sink, "base.tar");
/* In the main tar, include the backup_label first... */
backup_label = build_backup_content(backup_state, false);
sendFileWithContent(sink, BACKUP_LABEL_FILE,
- backup_label->data, &manifest);
- pfree(backup_label->data);
+ backup_label, &manifest);
pfree(backup_label);
/* Then the tablespace_map file, if required... */
#define XLOG_BACKUP_H
#include "access/xlogdefs.h"
-#include "lib/stringinfo.h"
#include "pgtime.h"
/* Structure to hold backup state. */
pg_time_t stoptime; /* backup stop time */
} BackupState;
-extern StringInfo build_backup_content(BackupState *state,
- bool ishistoryfile);
+extern char *build_backup_content(BackupState *state,
+ bool ishistoryfile);
#endif /* XLOG_BACKUP_H */