Skip to content

Commit 8046465

Browse files
committed
Fix pg_basebackup output to stdout on Windows.
When writing a backup to stdout with pg_basebackup on Windows, put stdout to binary mode. Any CR bytes in the output will otherwise be output incorrectly as CR+LF. In the passing, standardize on using "_setmode" instead of "setmode", for the sake of consistency. They both do the same thing, but according to MSDN documentation, setmode is deprecated. Fixes bug #14634, reported by Henry Boehlert. Patch by Haribabu Kommi. Backpatch to all supported versions. Discussion: https://www.postgresql.org/message-id/20170428082818.24366.13134@wrigleys.postgresql.org
1 parent a3ca72a commit 8046465

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,10 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
954954
*/
955955
if (strcmp(basedir, "-") == 0)
956956
{
957+
#ifdef WIN32
958+
_setmode(fileno(stdout), _O_BINARY);
959+
#endif
960+
957961
#ifdef HAVE_LIBZ
958962
if (compresslevel != 0)
959963
{

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,9 +2346,9 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
23462346
(AH->fSpec == NULL || strcmp(AH->fSpec, "") == 0))
23472347
{
23482348
if (mode == archModeWrite)
2349-
setmode(fileno(stdout), O_BINARY);
2349+
_setmode(fileno(stdout), O_BINARY);
23502350
else
2351-
setmode(fileno(stdin), O_BINARY);
2351+
_setmode(fileno(stdin), O_BINARY);
23522352
}
23532353
#endif
23542354

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy