aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_archiver.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2007-01-25 03:30:43 +0000
committerBruce Momjian <bruce@momjian.us>2007-01-25 03:30:43 +0000
commit6441288ec9d6c86c441ca31eb08799f12bc3b99c (patch)
tree8b46e7abe146f74d64c0dc02dd12d6342e656461 /src/bin/pg_dump/pg_backup_archiver.c
parent1b7d863f1df9b64acd8ed3d740a6ff246d006a96 (diff)
downloadpostgresql-6441288ec9d6c86c441ca31eb08799f12bc3b99c.tar.gz
postgresql-6441288ec9d6c86c441ca31eb08799f12bc3b99c.zip
Add 'output file' option for pg_dumpall, especially useful for Win32,
where output redirection of child processes (pg_dump) doesn't work. Dave Page
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index a4c5d6d7128..cd84c608827 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.139 2007/01/23 17:54:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.140 2007/01/25 03:30:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -86,10 +86,10 @@ static void ResetOutput(ArchiveHandle *AH, OutputContext savedContext);
/* Public */
Archive *
CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
- const int compression)
+ const int compression, ArchiveMode mode)
{
- ArchiveHandle *AH = _allocAH(FileSpec, fmt, compression, archModeWrite);
+ ArchiveHandle *AH = _allocAH(FileSpec, fmt, compression, mode);
return (Archive *) AH;
}
@@ -203,7 +203,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* Setup the output file if necessary.
- */
+ */
if (ropt->filename || ropt->compression)
sav = SetOutput(AH, ropt->filename, ropt->compression);
@@ -940,10 +940,20 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression)
else
#endif
{ /* Use fopen */
- if (fn >= 0)
- AH->OF = fdopen(dup(fn), PG_BINARY_W);
+ if (AH->mode == archModeAppend)
+ {
+ if (fn >= 0)
+ AH->OF = fdopen(dup(fn), PG_BINARY_A);
+ else
+ AH->OF = fopen(filename, PG_BINARY_A);
+ }
else
- AH->OF = fopen(filename, PG_BINARY_W);
+ {
+ if (fn >= 0)
+ AH->OF = fdopen(dup(fn), PG_BINARY_W);
+ else
+ AH->OF = fopen(filename, PG_BINARY_W);
+ }
AH->gzOut = 0;
}