Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3989dbd

Browse files
committed
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
1 parent 299298b commit 3989dbd

File tree

3 files changed

+65
-59
lines changed

3 files changed

+65
-59
lines changed

src/backend/replication/backup_manifest.c

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "utils/builtins.h"
2121
#include "utils/json.h"
2222

23+
static void AppendStringToManifest(backup_manifest_info *manifest, char *s);
24+
2325
/*
2426
* Does the user want a backup manifest?
2527
*
@@ -28,7 +30,7 @@
2830
* want a manifest, we set manifest->buffile to NULL.
2931
*/
3032
static inline bool
31-
IsManifestEnabled(manifest_info *manifest)
33+
IsManifestEnabled(backup_manifest_info *manifest)
3234
{
3335
return (manifest->buffile != NULL);
3436
}
@@ -51,8 +53,9 @@ IsManifestEnabled(manifest_info *manifest)
5153
* SendBackupManifest.
5254
*/
5355
void
54-
InitializeManifest(manifest_info *manifest, manifest_option want_manifest,
55-
pg_checksum_type manifest_checksum_type)
56+
InitializeBackupManifest(backup_manifest_info *manifest,
57+
backup_manifest_option want_manifest,
58+
pg_checksum_type manifest_checksum_type)
5659
{
5760
if (want_manifest == MANIFEST_OPTION_NO)
5861
manifest->buffile = NULL;
@@ -71,33 +74,13 @@ InitializeManifest(manifest_info *manifest, manifest_option want_manifest,
7174
"\"Files\": [");
7275
}
7376

74-
/*
75-
* Append a cstring to the manifest.
76-
*/
77-
void
78-
AppendStringToManifest(manifest_info *manifest, char *s)
79-
{
80-
int len = strlen(s);
81-
size_t written;
82-
83-
Assert(manifest != NULL);
84-
if (manifest->still_checksumming)
85-
pg_sha256_update(&manifest->manifest_ctx, (uint8 *) s, len);
86-
written = BufFileWrite(manifest->buffile, s, len);
87-
if (written != len)
88-
ereport(ERROR,
89-
(errcode_for_file_access(),
90-
errmsg("could not write to temporary file: %m")));
91-
manifest->manifest_size += len;
92-
}
93-
9477
/*
9578
* Add an entry to the backup manifest for a file.
9679
*/
9780
void
98-
AddFileToManifest(manifest_info *manifest, const char *spcoid,
99-
const char *pathname, size_t size, pg_time_t mtime,
100-
pg_checksum_context *checksum_ctx)
81+
AddFileToBackupManifest(backup_manifest_info *manifest, const char *spcoid,
82+
const char *pathname, size_t size, pg_time_t mtime,
83+
pg_checksum_context * checksum_ctx)
10184
{
10285
char pathbuf[MAXPGPATH];
10386
int pathlen;
@@ -203,8 +186,9 @@ AddFileToManifest(manifest_info *manifest, const char *spcoid,
203186
* this backup to the manifest.
204187
*/
205188
void
206-
AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
207-
TimeLineID starttli, XLogRecPtr endptr, TimeLineID endtli)
189+
AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
190+
TimeLineID starttli, XLogRecPtr endptr,
191+
TimeLineID endtli)
208192
{
209193
List *timelines;
210194
ListCell *lc;
@@ -299,7 +283,7 @@ AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
299283
* Finalize the backup manifest, and send it to the client.
300284
*/
301285
void
302-
SendBackupManifest(manifest_info *manifest)
286+
SendBackupManifest(backup_manifest_info *manifest)
303287
{
304288
StringInfoData protobuf;
305289
uint8 checksumbuf[PG_SHA256_DIGEST_LENGTH];
@@ -373,3 +357,23 @@ SendBackupManifest(manifest_info *manifest)
373357
/* Release resources */
374358
BufFileClose(manifest->buffile);
375359
}
360+
361+
/*
362+
* Append a cstring to the manifest.
363+
*/
364+
static void
365+
AppendStringToManifest(backup_manifest_info *manifest, char *s)
366+
{
367+
int len = strlen(s);
368+
size_t written;
369+
370+
Assert(manifest != NULL);
371+
if (manifest->still_checksumming)
372+
pg_sha256_update(&manifest->manifest_ctx, (uint8 *) s, len);
373+
written = BufFileWrite(manifest->buffile, s, len);
374+
if (written != len)
375+
ereport(ERROR,
376+
(errcode_for_file_access(),
377+
errmsg("could not write to temporary file: %m")));
378+
manifest->manifest_size += len;
379+
}

src/backend/replication/basebackup.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ typedef struct
5454
bool includewal;
5555
uint32 maxrate;
5656
bool sendtblspcmapfile;
57-
manifest_option manifest;
57+
backup_manifest_option manifest;
5858
pg_checksum_type manifest_checksum_type;
5959
} basebackup_options;
6060

6161
static int64 sendDir(const char *path, int basepathlen, bool sizeonly,
6262
List *tablespaces, bool sendtblspclinks,
63-
manifest_info *manifest, const char *spcoid);
63+
backup_manifest_info *manifest, const char *spcoid);
6464
static bool sendFile(const char *readfilename, const char *tarfilename,
6565
struct stat *statbuf, bool missing_ok, Oid dboid,
66-
manifest_info *manifest, const char *spcoid);
66+
backup_manifest_info *manifest, const char *spcoid);
6767
static void sendFileWithContent(const char *filename, const char *content,
68-
manifest_info *manifest);
68+
backup_manifest_info *manifest);
6969
static int64 _tarWriteHeader(const char *filename, const char *linktarget,
7070
struct stat *statbuf, bool sizeonly);
7171
static int64 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
@@ -268,7 +268,7 @@ perform_base_backup(basebackup_options *opt)
268268
TimeLineID endtli;
269269
StringInfo labelfile;
270270
StringInfo tblspc_map_file = NULL;
271-
manifest_info manifest;
271+
backup_manifest_info manifest;
272272
int datadirpathlen;
273273
List *tablespaces = NIL;
274274

@@ -298,7 +298,8 @@ perform_base_backup(basebackup_options *opt)
298298

299299
labelfile = makeStringInfo();
300300
tblspc_map_file = makeStringInfo();
301-
InitializeManifest(&manifest, opt->manifest, opt->manifest_checksum_type);
301+
InitializeBackupManifest(&manifest, opt->manifest,
302+
opt->manifest_checksum_type);
302303

303304
total_checksum_failures = 0;
304305

@@ -710,7 +711,7 @@ perform_base_backup(basebackup_options *opt)
710711
pq_putemptymessage('c');
711712
}
712713

713-
AddWALInfoToManifest(&manifest, startptr, starttli, endptr, endtli);
714+
AddWALInfoToBackupManifest(&manifest, startptr, starttli, endptr, endtli);
714715

715716
SendBackupManifest(&manifest);
716717

@@ -1085,7 +1086,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
10851086
*/
10861087
static void
10871088
sendFileWithContent(const char *filename, const char *content,
1088-
manifest_info *manifest)
1089+
backup_manifest_info *manifest)
10891090
{
10901091
struct stat statbuf;
10911092
int pad,
@@ -1129,9 +1130,8 @@ sendFileWithContent(const char *filename, const char *content,
11291130
}
11301131

11311132
pg_checksum_update(&checksum_ctx, (uint8 *) content, len);
1132-
AddFileToManifest(manifest, NULL, filename, len,
1133-
(pg_time_t) statbuf.st_mtime,
1134-
&checksum_ctx);
1133+
AddFileToBackupManifest(manifest, NULL, filename, len,
1134+
(pg_time_t) statbuf.st_mtime, &checksum_ctx);
11351135
}
11361136

11371137
/*
@@ -1143,7 +1143,7 @@ sendFileWithContent(const char *filename, const char *content,
11431143
*/
11441144
int64
11451145
sendTablespace(char *path, char *spcoid, bool sizeonly,
1146-
manifest_info *manifest)
1146+
backup_manifest_info *manifest)
11471147
{
11481148
int64 size;
11491149
char pathbuf[MAXPGPATH];
@@ -1196,7 +1196,8 @@ sendTablespace(char *path, char *spcoid, bool sizeonly,
11961196
*/
11971197
static int64
11981198
sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
1199-
bool sendtblspclinks, manifest_info *manifest, const char *spcoid)
1199+
bool sendtblspclinks, backup_manifest_info *manifest,
1200+
const char *spcoid)
12001201
{
12011202
DIR *dir;
12021203
struct dirent *de;
@@ -1558,7 +1559,7 @@ is_checksummed_file(const char *fullpath, const char *filename)
15581559
static bool
15591560
sendFile(const char *readfilename, const char *tarfilename,
15601561
struct stat *statbuf, bool missing_ok, Oid dboid,
1561-
manifest_info *manifest, const char *spcoid)
1562+
backup_manifest_info *manifest, const char *spcoid)
15621563
{
15631564
FILE *fp;
15641565
BlockNumber blkno = 0;
@@ -1810,8 +1811,8 @@ sendFile(const char *readfilename, const char *tarfilename,
18101811

18111812
total_checksum_failures += checksum_failures;
18121813

1813-
AddFileToManifest(manifest, spcoid, tarfilename, statbuf->st_size,
1814-
(pg_time_t) statbuf->st_mtime, &checksum_ctx);
1814+
AddFileToBackupManifest(manifest, spcoid, tarfilename, statbuf->st_size,
1815+
(pg_time_t) statbuf->st_mtime, &checksum_ctx);
18151816

18161817
return true;
18171818
}

src/include/replication/backup_manifest.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef enum manifest_option
2222
MANIFEST_OPTION_YES,
2323
MANIFEST_OPTION_NO,
2424
MANIFEST_OPTION_FORCE_ENCODE
25-
} manifest_option;
25+
} backup_manifest_option;
2626

2727
typedef struct manifest_info
2828
{
@@ -33,19 +33,20 @@ typedef struct manifest_info
3333
bool force_encode;
3434
bool first_file;
3535
bool still_checksumming;
36-
} manifest_info;
36+
} backup_manifest_info;
3737

38-
extern void InitializeManifest(manifest_info *manifest,
39-
manifest_option want_manifest,
40-
pg_checksum_type manifest_checksum_type);
41-
extern void AppendStringToManifest(manifest_info *manifest, char *s);
42-
extern void AddFileToManifest(manifest_info *manifest, const char *spcoid,
43-
const char *pathname, size_t size,
44-
pg_time_t mtime,
45-
pg_checksum_context *checksum_ctx);
46-
extern void AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
47-
TimeLineID starttli, XLogRecPtr endptr,
48-
TimeLineID endtli);
49-
extern void SendBackupManifest(manifest_info *manifest);
38+
extern void InitializeBackupManifest(backup_manifest_info *manifest,
39+
backup_manifest_option want_manifest,
40+
pg_checksum_type manifest_checksum_type);
41+
extern void AddFileToBackupManifest(backup_manifest_info *manifest,
42+
const char *spcoid,
43+
const char *pathname, size_t size,
44+
pg_time_t mtime,
45+
pg_checksum_context * checksum_ctx);
46+
extern void AddWALInfoToBackupManifest(backup_manifest_info *manifest,
47+
XLogRecPtr startptr,
48+
TimeLineID starttli, XLogRecPtr endptr,
49+
TimeLineID endtli);
50+
extern void SendBackupManifest(backup_manifest_info *manifest);
5051

5152
#endif

0 commit comments

Comments
 (0)