summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2020-04-23 12:44:06 +0000
committerRobert Haas2020-04-23 12:44:06 +0000
commit3989dbdf1293ecc16991065a3d84857a945ea853 (patch)
tree810df1d5a7c6d18fda4095f7e0b3aed9f9d9a418
parent299298bc873374ed49fa2f39944c09ac62bd75e3 (diff)
Rename exposed identifiers to say "backup manifest".
Function names declared "extern" now use BackupManifest in the name rather than just Manifest, and data types use backup_manifest rather than just manifest. Per note from Michael Paquier. Discussion: http://postgr.es/m/20200418125713.GG350229@paquier.xyz
-rw-r--r--src/backend/replication/backup_manifest.c62
-rw-r--r--src/backend/replication/basebackup.c33
-rw-r--r--src/include/replication/backup_manifest.h29
3 files changed, 65 insertions, 59 deletions
diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index 8aead70726a..d2f454c60ef 100644
--- a/src/backend/replication/backup_manifest.c
+++ b/src/backend/replication/backup_manifest.c
@@ -20,6 +20,8 @@
#include "utils/builtins.h"
#include "utils/json.h"
+static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
+
/*
* Does the user want a backup manifest?
*
@@ -28,7 +30,7 @@
* want a manifest, we set manifest->buffile to NULL.
*/
static inline bool
-IsManifestEnabled(manifest_info *manifest)
+IsManifestEnabled(backup_manifest_info *manifest)
{
return (manifest->buffile != NULL);
}
@@ -51,8 +53,9 @@ IsManifestEnabled(manifest_info *manifest)
* SendBackupManifest.
*/
void
-InitializeManifest(manifest_info *manifest, manifest_option want_manifest,
- pg_checksum_type manifest_checksum_type)
+InitializeBackupManifest(backup_manifest_info *manifest,
+ backup_manifest_option want_manifest,
+ pg_checksum_type manifest_checksum_type)
{
if (want_manifest == MANIFEST_OPTION_NO)
manifest->buffile = NULL;
@@ -72,32 +75,12 @@ InitializeManifest(manifest_info *manifest, manifest_option want_manifest,
}
/*
- * Append a cstring to the manifest.
- */
-void
-AppendStringToManifest(manifest_info *manifest, char *s)
-{
- int len = strlen(s);
- size_t written;
-
- Assert(manifest != NULL);
- if (manifest->still_checksumming)
- pg_sha256_update(&manifest->manifest_ctx, (uint8 *) s, len);
- written = BufFileWrite(manifest->buffile, s, len);
- if (written != len)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not write to temporary file: %m")));
- manifest->manifest_size += len;
-}
-
-/*
* Add an entry to the backup manifest for a file.
*/
void
-AddFileToManifest(manifest_info *manifest, const char *spcoid,
- const char *pathname, size_t size, pg_time_t mtime,
- pg_checksum_context *checksum_ctx)
+AddFileToBackupManifest(backup_manifest_info *manifest, const char *spcoid,
+ const char *pathname, size_t size, pg_time_t mtime,
+ pg_checksum_context * checksum_ctx)
{
char pathbuf[MAXPGPATH];
int pathlen;
@@ -203,8 +186,9 @@ AddFileToManifest(manifest_info *manifest, const char *spcoid,
* this backup to the manifest.
*/
void
-AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
- TimeLineID starttli, XLogRecPtr endptr, TimeLineID endtli)
+AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
+ TimeLineID starttli, XLogRecPtr endptr,
+ TimeLineID endtli)
{
List *timelines;
ListCell *lc;
@@ -299,7 +283,7 @@ AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
* Finalize the backup manifest, and send it to the client.
*/
void
-SendBackupManifest(manifest_info *manifest)
+SendBackupManifest(backup_manifest_info *manifest)
{
StringInfoData protobuf;
uint8 checksumbuf[PG_SHA256_DIGEST_LENGTH];
@@ -373,3 +357,23 @@ SendBackupManifest(manifest_info *manifest)
/* Release resources */
BufFileClose(manifest->buffile);
}
+
+/*
+ * Append a cstring to the manifest.
+ */
+static void
+AppendStringToManifest(backup_manifest_info *manifest, char *s)
+{
+ int len = strlen(s);
+ size_t written;
+
+ Assert(manifest != NULL);
+ if (manifest->still_checksumming)
+ pg_sha256_update(&manifest->manifest_ctx, (uint8 *) s, len);
+ written = BufFileWrite(manifest->buffile, s, len);
+ if (written != len)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not write to temporary file: %m")));
+ manifest->manifest_size += len;
+}
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index f3fb5716a4b..fbdc28ec399 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -54,18 +54,18 @@ typedef struct
bool includewal;
uint32 maxrate;
bool sendtblspcmapfile;
- manifest_option manifest;
+ backup_manifest_option manifest;
pg_checksum_type manifest_checksum_type;
} basebackup_options;
static int64 sendDir(const char *path, int basepathlen, bool sizeonly,
List *tablespaces, bool sendtblspclinks,
- manifest_info *manifest, const char *spcoid);
+ backup_manifest_info *manifest, const char *spcoid);
static bool sendFile(const char *readfilename, const char *tarfilename,
struct stat *statbuf, bool missing_ok, Oid dboid,
- manifest_info *manifest, const char *spcoid);
+ backup_manifest_info *manifest, const char *spcoid);
static void sendFileWithContent(const char *filename, const char *content,
- manifest_info *manifest);
+ backup_manifest_info *manifest);
static int64 _tarWriteHeader(const char *filename, const char *linktarget,
struct stat *statbuf, bool sizeonly);
static int64 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
@@ -268,7 +268,7 @@ perform_base_backup(basebackup_options *opt)
TimeLineID endtli;
StringInfo labelfile;
StringInfo tblspc_map_file = NULL;
- manifest_info manifest;
+ backup_manifest_info manifest;
int datadirpathlen;
List *tablespaces = NIL;
@@ -298,7 +298,8 @@ perform_base_backup(basebackup_options *opt)
labelfile = makeStringInfo();
tblspc_map_file = makeStringInfo();
- InitializeManifest(&manifest, opt->manifest, opt->manifest_checksum_type);
+ InitializeBackupManifest(&manifest, opt->manifest,
+ opt->manifest_checksum_type);
total_checksum_failures = 0;
@@ -710,7 +711,7 @@ perform_base_backup(basebackup_options *opt)
pq_putemptymessage('c');
}
- AddWALInfoToManifest(&manifest, startptr, starttli, endptr, endtli);
+ AddWALInfoToBackupManifest(&manifest, startptr, starttli, endptr, endtli);
SendBackupManifest(&manifest);
@@ -1085,7 +1086,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
*/
static void
sendFileWithContent(const char *filename, const char *content,
- manifest_info *manifest)
+ backup_manifest_info *manifest)
{
struct stat statbuf;
int pad,
@@ -1129,9 +1130,8 @@ sendFileWithContent(const char *filename, const char *content,
}
pg_checksum_update(&checksum_ctx, (uint8 *) content, len);
- AddFileToManifest(manifest, NULL, filename, len,
- (pg_time_t) statbuf.st_mtime,
- &checksum_ctx);
+ AddFileToBackupManifest(manifest, NULL, filename, len,
+ (pg_time_t) statbuf.st_mtime, &checksum_ctx);
}
/*
@@ -1143,7 +1143,7 @@ sendFileWithContent(const char *filename, const char *content,
*/
int64
sendTablespace(char *path, char *spcoid, bool sizeonly,
- manifest_info *manifest)
+ backup_manifest_info *manifest)
{
int64 size;
char pathbuf[MAXPGPATH];
@@ -1196,7 +1196,8 @@ sendTablespace(char *path, char *spcoid, bool sizeonly,
*/
static int64
sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
- bool sendtblspclinks, manifest_info *manifest, const char *spcoid)
+ bool sendtblspclinks, backup_manifest_info *manifest,
+ const char *spcoid)
{
DIR *dir;
struct dirent *de;
@@ -1558,7 +1559,7 @@ is_checksummed_file(const char *fullpath, const char *filename)
static bool
sendFile(const char *readfilename, const char *tarfilename,
struct stat *statbuf, bool missing_ok, Oid dboid,
- manifest_info *manifest, const char *spcoid)
+ backup_manifest_info *manifest, const char *spcoid)
{
FILE *fp;
BlockNumber blkno = 0;
@@ -1810,8 +1811,8 @@ sendFile(const char *readfilename, const char *tarfilename,
total_checksum_failures += checksum_failures;
- AddFileToManifest(manifest, spcoid, tarfilename, statbuf->st_size,
- (pg_time_t) statbuf->st_mtime, &checksum_ctx);
+ AddFileToBackupManifest(manifest, spcoid, tarfilename, statbuf->st_size,
+ (pg_time_t) statbuf->st_mtime, &checksum_ctx);
return true;
}
diff --git a/src/include/replication/backup_manifest.h b/src/include/replication/backup_manifest.h
index e7fccddd0da..fd614202b31 100644
--- a/src/include/replication/backup_manifest.h
+++ b/src/include/replication/backup_manifest.h
@@ -22,7 +22,7 @@ typedef enum manifest_option
MANIFEST_OPTION_YES,
MANIFEST_OPTION_NO,
MANIFEST_OPTION_FORCE_ENCODE
-} manifest_option;
+} backup_manifest_option;
typedef struct manifest_info
{
@@ -33,19 +33,20 @@ typedef struct manifest_info
bool force_encode;
bool first_file;
bool still_checksumming;
-} manifest_info;
+} backup_manifest_info;
-extern void InitializeManifest(manifest_info *manifest,
- manifest_option want_manifest,
- pg_checksum_type manifest_checksum_type);
-extern void AppendStringToManifest(manifest_info *manifest, char *s);
-extern void AddFileToManifest(manifest_info *manifest, const char *spcoid,
- const char *pathname, size_t size,
- pg_time_t mtime,
- pg_checksum_context *checksum_ctx);
-extern void AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
- TimeLineID starttli, XLogRecPtr endptr,
- TimeLineID endtli);
-extern void SendBackupManifest(manifest_info *manifest);
+extern void InitializeBackupManifest(backup_manifest_info *manifest,
+ backup_manifest_option want_manifest,
+ pg_checksum_type manifest_checksum_type);
+extern void AddFileToBackupManifest(backup_manifest_info *manifest,
+ const char *spcoid,
+ const char *pathname, size_t size,
+ pg_time_t mtime,
+ pg_checksum_context * checksum_ctx);
+extern void AddWALInfoToBackupManifest(backup_manifest_info *manifest,
+ XLogRecPtr startptr,
+ TimeLineID starttli, XLogRecPtr endptr,
+ TimeLineID endtli);
+extern void SendBackupManifest(backup_manifest_info *manifest);
#endif