From b76a316d1baa80dcc70c81b539f6d14f04556983 Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Mon, 20 Apr 2020 14:51:05 -0400
Subject: [PATCH] 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
---
 src/backend/replication/backup_manifest.c | 62 ++++++++++++-----------
 src/backend/replication/basebackup.c      | 16 +++---
 src/include/replication/backup_manifest.h | 29 ++++++-----
 3 files changed, 56 insertions(+), 51 deletions(-)

diff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.c
index 8aead70726..bef02113d9 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;
@@ -71,33 +74,13 @@ InitializeManifest(manifest_info *manifest, manifest_option want_manifest,
 						 "\"Files\": [");
 }
 
-/*
- * 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(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 f3fb5716a4..b59542d56b 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -54,7 +54,7 @@ typedef struct
 	bool		includewal;
 	uint32		maxrate;
 	bool		sendtblspcmapfile;
-	manifest_option manifest;
+	backup_manifest_option manifest;
 	pg_checksum_type manifest_checksum_type;
 } basebackup_options;
 
@@ -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);
 
@@ -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);
 }
 
 /*
@@ -1810,8 +1810,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 e7fccddd0d..fd614202b3 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
-- 
2.24.2 (Apple Git-127)

