aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_custom.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2006-05-22 11:21:54 +0000
committerPeter Eisentraut <peter_e@gmx.net>2006-05-22 11:21:54 +0000
commit79e371037b960208c7febb4b292fb701a3f2a862 (patch)
tree75ba34f3c29966e5b285b320226054d322bfafa1 /src/bin/pg_dump/pg_backup_custom.c
parente9cc53025ad4bf3a1a7287192ba47fbbf4aac826 (diff)
downloadpostgresql-79e371037b960208c7febb4b292fb701a3f2a862.tar.gz
postgresql-79e371037b960208c7febb4b292fb701a3f2a862.zip
Add strerror to pg_dump error messages where missing.
Diffstat (limited to 'src/bin/pg_dump/pg_backup_custom.c')
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 3edbb8f5c0a..41b7bc23135 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.33 2005/10/15 02:49:38 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.34 2006/05/22 11:21:54 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -175,7 +175,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
AH->FH = stdout;
if (!AH->FH)
- die_horribly(AH, modulename, "could not open archive file \"%s\": %s\n", AH->fSpec, strerror(errno));
+ die_horribly(AH, modulename, "could not open output file \"%s\": %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = checkSeek(AH->FH);
}
@@ -186,7 +186,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
else
AH->FH = stdin;
if (!AH->FH)
- die_horribly(AH, modulename, "could not open archive file \"%s\": %s\n", AH->fSpec, strerror(errno));
+ die_horribly(AH, modulename, "could not open input file \"%s\": %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = checkSeek(AH->FH);
@@ -438,7 +438,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{
if ((TocIDRequired(AH, id, ropt) & REQ_DATA) != 0)
die_horribly(AH, modulename,
- "Dumping a specific TOC data block out of order is not supported"
+ "dumping a specific TOC data block out of order is not supported"
" without ID on this input stream (fseek required)\n");
switch (blkType)
@@ -540,9 +540,14 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen)
- die_horribly(AH, modulename,
- "could not read data block -- expected %lu, got %lu\n",
- (unsigned long) blkLen, (unsigned long) cnt);
+ {
+ if (feof(AH->FH))
+ die_horribly(AH, modulename,
+ "could not read from input file: end of file\n");
+ else
+ die_horribly(AH, modulename,
+ "could not read from input file: %s\n", strerror(errno));
+ }
ctx->filePos += blkLen;
@@ -663,9 +668,14 @@ _skipData(ArchiveHandle *AH)
}
cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen)
- die_horribly(AH, modulename,
- "could not read data block -- expected %lu, got %lu\n",
- (unsigned long) blkLen, (unsigned long) cnt);
+ {
+ if (feof(AH->FH))
+ die_horribly(AH, modulename,
+ "could not read from input file: end of file\n");
+ else
+ die_horribly(AH, modulename,
+ "could not read from input file: %s\n", strerror(errno));
+ }
ctx->filePos += blkLen;
@@ -736,8 +746,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
if (res != len)
die_horribly(AH, modulename,
- "write error in _WriteBuf (%lu != %lu)\n",
- (unsigned long) res, (unsigned long) len);
+ "could not write to output file: %s\n", strerror(errno));
ctx->filePos += res;
return res;
@@ -929,7 +938,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
*/
WriteInt(AH, zlibOutSize - zp->avail_out);
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
- die_horribly(AH, modulename, "could not write compressed chunk\n");
+ die_horribly(AH, modulename, "could not write to output file: %s\n", strerror(errno));
ctx->filePos += zlibOutSize - zp->avail_out;
}
zp->next_out = (void *) out;
@@ -943,7 +952,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
{
WriteInt(AH, zp->avail_in);
if (fwrite(zp->next_in, 1, zp->avail_in, AH->FH) != zp->avail_in)
- die_horribly(AH, modulename, "could not write uncompressed chunk\n");
+ die_horribly(AH, modulename, "could not write to output file: %s\n", strerror(errno));
ctx->filePos += zp->avail_in;
zp->avail_in = 0;
}