pg_basebackup_tar_to_stdout_windows_fix.patch

application/octet-stream

Filename: pg_basebackup_tar_to_stdout_windows_fix.patch
Type: application/octet-stream
Part: 0
Message: Re: [BUGS] BUG #14634: On Windows pg_basebackup should write tar to stdout in binary mode

Patch

Format: unified
File+
src/bin/pg_basebackup/pg_basebackup.c 4 0
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index e2a2ebb..86e015c 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -954,6 +954,10 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
 		 */
 		if (strcmp(basedir, "-") == 0)
 		{
+#ifdef WIN32
+			_setmode(fileno(stdout), _O_BINARY);
+#endif
+
 #ifdef HAVE_LIBZ
 			if (compresslevel != 0)
 			{