0002-Rename-sizeonly-to-dryrun-for-few-functions-in-baseb.patch

application/octet-stream

Filename: 0002-Rename-sizeonly-to-dryrun-for-few-functions-in-baseb.patch
Type: application/octet-stream
Part: 3
Message: Re: WIP/PoC for parallel backup

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0002
Subject: Rename sizeonly to dryrun for few functions in basebackup.
File+
src/backend/replication/basebackup.c 22 22
src/include/replication/basebackup.h 1 1
From f24c0bfcae411b38d689523d0329d830d9aa191f Mon Sep 17 00:00:00 2001
From: Asif Rehman <asif.rehman@highgo.ca>
Date: Wed, 30 Oct 2019 16:45:28 +0500
Subject: [PATCH 2/7] Rename sizeonly to dryrun for few functions in
 basebackup.

---
 src/backend/replication/basebackup.c | 44 ++++++++++++++--------------
 src/include/replication/basebackup.h |  2 +-
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 71a8b4fb4c..267163ed29 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -54,15 +54,15 @@ typedef struct
 } basebackup_options;
 
 
-static int64 sendDir(const char *path, int basepathlen, bool sizeonly,
+static int64 sendDir(const char *path, int basepathlen, bool dryrun,
 					 List *tablespaces, bool sendtblspclinks);
 static bool sendFile(const char *readfilename, const char *tarfilename,
 					 struct stat *statbuf, bool missing_ok, Oid dboid);
 static void sendFileWithContent(const char *filename, const char *content);
 static int64 _tarWriteHeader(const char *filename, const char *linktarget,
-							 struct stat *statbuf, bool sizeonly);
+							 struct stat *statbuf, bool dryrun);
 static int64 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
-						  bool sizeonly);
+						  bool dryrun);
 static void send_int8_string(StringInfoData *buf, int64 intval);
 static void SendBackupHeader(List *tablespaces);
 static void base_backup_cleanup(int code, Datum arg);
@@ -959,13 +959,13 @@ sendFileWithContent(const char *filename, const char *content)
 
 /*
  * Include the tablespace directory pointed to by 'path' in the output tar
- * stream.  If 'sizeonly' is true, we just calculate a total length and return
+ * stream.  If 'dryrun' is true, we just calculate a total length and return
  * it, without actually sending anything.
  *
  * Only used to send auxiliary tablespaces, not PGDATA.
  */
 int64
-sendTablespace(char *path, bool sizeonly)
+sendTablespace(char *path, bool dryrun)
 {
 	int64		size;
 	char		pathbuf[MAXPGPATH];
@@ -995,17 +995,17 @@ sendTablespace(char *path, bool sizeonly)
 	}
 
 	size = _tarWriteHeader(TABLESPACE_VERSION_DIRECTORY, NULL, &statbuf,
-						   sizeonly);
+						   dryrun);
 
 	/* Send all the files in the tablespace version directory */
-	size += sendDir(pathbuf, strlen(path), sizeonly, NIL, true);
+	size += sendDir(pathbuf, strlen(path), dryrun, NIL, true);
 
 	return size;
 }
 
 /*
  * Include all files from the given directory in the output tar stream. If
- * 'sizeonly' is true, we just calculate a total length and return it, without
+ * 'dryrun' is true, we just calculate a total length and return it, without
  * actually sending anything.
  *
  * Omit any directory in the tablespaces list, to avoid backing up
@@ -1016,7 +1016,7 @@ sendTablespace(char *path, bool sizeonly)
  * as it will be sent separately in the tablespace_map file.
  */
 static int64
-sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
+sendDir(const char *path, int basepathlen, bool dryrun, List *tablespaces,
 		bool sendtblspclinks)
 {
 	DIR		   *dir;
@@ -1171,7 +1171,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 			if (strcmp(de->d_name, excludeDirContents[excludeIdx]) == 0)
 			{
 				elog(DEBUG1, "contents of directory \"%s\" excluded from backup", de->d_name);
-				size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly);
+				size += _tarWriteDir(pathbuf, basepathlen, &statbuf, dryrun);
 				excludeFound = true;
 				break;
 			}
@@ -1187,7 +1187,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 		if (statrelpath != NULL && strcmp(pathbuf, statrelpath) == 0)
 		{
 			elog(DEBUG1, "contents of directory \"%s\" excluded from backup", statrelpath);
-			size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly);
+			size += _tarWriteDir(pathbuf, basepathlen, &statbuf, dryrun);
 			continue;
 		}
 
@@ -1199,14 +1199,14 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 		if (strcmp(pathbuf, "./pg_wal") == 0)
 		{
 			/* If pg_wal is a symlink, write it as a directory anyway */
-			size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly);
+			size += _tarWriteDir(pathbuf, basepathlen, &statbuf, dryrun);
 
 			/*
 			 * Also send archive_status directory (by hackishly reusing
 			 * statbuf from above ...).
 			 */
 			size += _tarWriteHeader("./pg_wal/archive_status", NULL, &statbuf,
-									sizeonly);
+									dryrun);
 
 			continue;			/* don't recurse into pg_wal */
 		}
@@ -1238,7 +1238,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 			linkpath[rllen] = '\0';
 
 			size += _tarWriteHeader(pathbuf + basepathlen + 1, linkpath,
-									&statbuf, sizeonly);
+									&statbuf, dryrun);
 #else
 
 			/*
@@ -1262,7 +1262,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 			 * permissions right.
 			 */
 			size += _tarWriteHeader(pathbuf + basepathlen + 1, NULL, &statbuf,
-									sizeonly);
+									dryrun);
 
 			/*
 			 * Call ourselves recursively for a directory, unless it happens
@@ -1293,17 +1293,17 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 				skip_this_dir = true;
 
 			if (!skip_this_dir)
-				size += sendDir(pathbuf, basepathlen, sizeonly, tablespaces, sendtblspclinks);
+				size += sendDir(pathbuf, basepathlen, dryrun, tablespaces, sendtblspclinks);
 		}
 		else if (S_ISREG(statbuf.st_mode))
 		{
 			bool		sent = false;
 
-			if (!sizeonly)
+			if (!dryrun)
 				sent = sendFile(pathbuf, pathbuf + basepathlen + 1, &statbuf,
 								true, isDbDir ? pg_atoi(lastDir + 1, sizeof(Oid), 0) : InvalidOid);
 
-			if (sent || sizeonly)
+			if (sent || dryrun)
 			{
 				/* Add size, rounded up to 512byte block */
 				size += ((statbuf.st_size + 511) & ~511);
@@ -1612,12 +1612,12 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
 
 static int64
 _tarWriteHeader(const char *filename, const char *linktarget,
-				struct stat *statbuf, bool sizeonly)
+				struct stat *statbuf, bool dryrun)
 {
 	char		h[512];
 	enum tarError rc;
 
-	if (!sizeonly)
+	if (!dryrun)
 	{
 		rc = tarCreateHeader(h, filename, linktarget, statbuf->st_size,
 							 statbuf->st_mode, statbuf->st_uid, statbuf->st_gid,
@@ -1654,7 +1654,7 @@ _tarWriteHeader(const char *filename, const char *linktarget,
  */
 static int64
 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
-			 bool sizeonly)
+			 bool dryrun)
 {
 	/* If symlink, write it as a directory anyway */
 #ifndef WIN32
@@ -1664,7 +1664,7 @@ _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
 #endif
 		statbuf->st_mode = S_IFDIR | pg_dir_create_mode;
 
-	return _tarWriteHeader(pathbuf + basepathlen + 1, NULL, statbuf, sizeonly);
+	return _tarWriteHeader(pathbuf + basepathlen + 1, NULL, statbuf, dryrun);
 }
 
 /*
diff --git a/src/include/replication/basebackup.h b/src/include/replication/basebackup.h
index 503a5b9f0b..b55917b9b6 100644
--- a/src/include/replication/basebackup.h
+++ b/src/include/replication/basebackup.h
@@ -31,6 +31,6 @@ typedef struct
 
 extern void SendBaseBackup(BaseBackupCmd *cmd);
 
-extern int64 sendTablespace(char *path, bool sizeonly);
+extern int64 sendTablespace(char *path, bool dryrun);
 
 #endif							/* _BASEBACKUP_H */
-- 
2.21.0 (Apple Git-122.2)