mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
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.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.60 2007/08/29 16:31:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.61 2007/10/28 21:55:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -172,15 +172,22 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
|
||||
*/
|
||||
if (AH->mode == archModeWrite)
|
||||
{
|
||||
|
||||
if (AH->fSpec && strcmp(AH->fSpec, "") != 0)
|
||||
{
|
||||
ctx->tarFH = fopen(AH->fSpec, PG_BINARY_W);
|
||||
if (ctx->tarFH == NULL)
|
||||
die_horribly(NULL, modulename,
|
||||
"could not open TOC file \"%s\" for output: %s\n",
|
||||
AH->fSpec, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->tarFH = stdout;
|
||||
|
||||
if (ctx->tarFH == NULL)
|
||||
die_horribly(NULL, modulename,
|
||||
"could not open TOC file for output: %s\n", strerror(errno));
|
||||
if (ctx->tarFH == NULL)
|
||||
die_horribly(NULL, modulename,
|
||||
"could not open TOC file for output: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
ctx->tarFHpos = 0;
|
||||
|
||||
@@ -210,14 +217,20 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
|
||||
}
|
||||
else
|
||||
{ /* Read Mode */
|
||||
|
||||
if (AH->fSpec && strcmp(AH->fSpec, "") != 0)
|
||||
{
|
||||
ctx->tarFH = fopen(AH->fSpec, PG_BINARY_R);
|
||||
if (ctx->tarFH == NULL)
|
||||
die_horribly(NULL, modulename, "could not open TOC file \"%s\" for input: %s\n",
|
||||
AH->fSpec, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->tarFH = stdin;
|
||||
|
||||
if (ctx->tarFH == NULL)
|
||||
die_horribly(NULL, modulename, "could not open TOC file for input: %s\n", strerror(errno));
|
||||
if (ctx->tarFH == NULL)
|
||||
die_horribly(NULL, modulename, "could not open TOC file for input: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* Make unbuffered since we will dup() it, and the buffers screw each
|
||||
|
Reference in New Issue
Block a user