summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_custom.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-10-28 21:55:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-10-28 21:55:52 +0000
commit27c033ed98d0ed8ee05caf440ae648f42fa5f9d6 (patch)
tree5e4bda42662ec4fb2237e3ee25b5bd0b3e97f452 /src/bin/pg_dump/pg_backup_custom.c
parent006f42c74d46505b2b4dc753be25c91b0f9efec5 (diff)
Make pg_dump and friends consistently report both the filename and the
errno string when complaining of fopen failures. Per gripe from Bob Pawley, it's not always instantly obvious to the user which name we tried to open.
Diffstat (limited to 'src/bin/pg_dump/pg_backup_custom.c')
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 923acce55a9..5791ec78128 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.39 2007/08/06 01:38:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.40 2007/10/28 21:55:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -169,23 +169,38 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (AH->mode == archModeWrite)
{
if (AH->fSpec && strcmp(AH->fSpec, "") != 0)
+ {
AH->FH = fopen(AH->fSpec, PG_BINARY_W);
+ if (!AH->FH)
+ die_horribly(AH, modulename, "could not open output file \"%s\": %s\n",
+ AH->fSpec, strerror(errno));
+ }
else
+ {
AH->FH = stdout;
-
- if (!AH->FH)
- die_horribly(AH, modulename, "could not open output file \"%s\": %s\n", AH->fSpec, strerror(errno));
+ if (!AH->FH)
+ die_horribly(AH, modulename, "could not open output file: %s\n",
+ strerror(errno));
+ }
ctx->hasSeek = checkSeek(AH->FH);
}
else
{
if (AH->fSpec && strcmp(AH->fSpec, "") != 0)
+ {
AH->FH = fopen(AH->fSpec, PG_BINARY_R);
+ if (!AH->FH)
+ die_horribly(AH, modulename, "could not open input file \"%s\": %s\n",
+ AH->fSpec, strerror(errno));
+ }
else
+ {
AH->FH = stdin;
- if (!AH->FH)
- die_horribly(AH, modulename, "could not open input file \"%s\": %s\n", AH->fSpec, strerror(errno));
+ if (!AH->FH)
+ die_horribly(AH, modulename, "could not open input file: %s\n",
+ strerror(errno));
+ }
ctx->hasSeek = checkSeek(AH->FH);