summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-01-26 19:44:43 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-01-26 19:44:43 +0000
commit9d58b9645e58e6ad12ac0c9cac353957948828fe (patch)
treed4b02cc88c97d77466f8d059bc42c7b92275be1f /src/bin/pg_dump
parent889f03812916b146ae504c0fad5afdc7bf2e8a2a (diff)
downloadpostgresql-9d58b9645e58e6ad12ac0c9cac353957948828fe.tar.gz
Make pg_dump and pg_restore handle binary archive formats correctly
when using stdout/stdin on Windows.
Diffstat (limited to 'src/bin/pg_dump')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index e3b99a9b1d..f008611827 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.103 2005/01/25 22:44:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.104 2005/01/26 19:44:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,6 +29,10 @@
#include <ctype.h>
#include <unistd.h>
+#ifdef WIN32
+#include <io.h>
+#endif
+
#include "pqexpbuffer.h"
#include "libpq/libpq-fs.h"
@@ -1709,6 +1713,21 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
AH->gzOut = 0;
AH->OF = stdout;
+ /*
+ * On Windows, we need to use binary mode to read/write non-text archive
+ * formats. Force stdin/stdout into binary mode in case that is what
+ * we are using.
+ */
+#ifdef WIN32
+ if (fmt != archNull)
+ {
+ if (mode == archModeWrite)
+ setmode(fileno(stdout), O_BINARY);
+ else
+ setmode(fileno(stdin), O_BINARY);
+ }
+#endif
+
#if 0
write_msg(modulename, "archive format is %d\n", fmt);
#endif
@@ -1720,7 +1739,6 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
switch (AH->format)
{
-
case archCustom:
InitArchiveFmt_Custom(AH);
break;