Rename exposed identifiers to say "backup manifest".
authorRobert Haas <rhaas@postgresql.org>
Thu, 23 Apr 2020 12:44:06 +0000 (08:44 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 23 Apr 2020 12:44:06 +0000 (08:44 -0400)
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
src/backend/replication/basebackup.c
src/include/replication/backup_manifest.h

index 8aead70726a9a96ffecb181565e3e21ba909005f..d2f454c60eff2cbf4aa87e674b1529c01f3f2d91 100644 (file)
@@ -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(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;
+}
index f3fb5716a4b33f6d397ff7d80ead98e869dd1092..fbdc28ec3999a39c3914e27fb4083061a73d25dc 100644 (file)
@@ -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;
 }
index e7fccddd0da39065312d927882a8b535dca1a4ee..fd614202b31d8dac95270ee7a183d62a2598d3f5 100644 (file)
@@ -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