mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
Add strerror to pg_dump error messages where missing.
This commit is contained in:
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.89 2006/03/05 15:58:50 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.90 2006/05/22 11:21:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -768,7 +768,7 @@ parseOidArray(const char *str, Oid *array, int arraysize)
|
|||||||
{
|
{
|
||||||
if (argNum >= arraysize)
|
if (argNum >= arraysize)
|
||||||
{
|
{
|
||||||
write_msg(NULL, "could not parse numeric array: too many numbers\n");
|
write_msg(NULL, "could not parse numeric array \"%s\": too many numbers\n", str);
|
||||||
exit_nicely();
|
exit_nicely();
|
||||||
}
|
}
|
||||||
temp[j] = '\0';
|
temp[j] = '\0';
|
||||||
@ -783,7 +783,7 @@ parseOidArray(const char *str, Oid *array, int arraysize)
|
|||||||
if (!(isdigit((unsigned char) s) || s == '-') ||
|
if (!(isdigit((unsigned char) s) || s == '-') ||
|
||||||
j >= sizeof(temp) - 1)
|
j >= sizeof(temp) - 1)
|
||||||
{
|
{
|
||||||
write_msg(NULL, "could not parse numeric array: invalid character in number\n");
|
write_msg(NULL, "could not parse numeric array \"%s\": invalid character in number\n", str);
|
||||||
exit_nicely();
|
exit_nicely();
|
||||||
}
|
}
|
||||||
temp[j++] = s;
|
temp[j++] = s;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.127 2006/04/19 16:02:17 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.128 2006/05/22 11:21:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -122,7 +122,8 @@ CloseArchive(Archive *AHX)
|
|||||||
res = fclose(AH->OF);
|
res = fclose(AH->OF);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
die_horribly(AH, modulename, "could not close output archive file\n");
|
die_horribly(AH, modulename, "could not close output file: %s\n",
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public */
|
/* Public */
|
||||||
@ -306,7 +307,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
|
|||||||
{
|
{
|
||||||
#ifndef HAVE_LIBZ
|
#ifndef HAVE_LIBZ
|
||||||
if (AH->compression != 0)
|
if (AH->compression != 0)
|
||||||
die_horribly(AH, modulename, "cannot restore from compressed archive (not configured for compression support)\n");
|
die_horribly(AH, modulename, "cannot restore from compressed archive (compression not supported in this installation)\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_printTocEntry(AH, te, ropt, true, false);
|
_printTocEntry(AH, te, ropt, true, false);
|
||||||
@ -774,7 +775,8 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
|
|||||||
/* Setup the file */
|
/* Setup the file */
|
||||||
fh = fopen(ropt->tocFile, PG_BINARY_R);
|
fh = fopen(ropt->tocFile, PG_BINARY_R);
|
||||||
if (!fh)
|
if (!fh)
|
||||||
die_horribly(AH, modulename, "could not open TOC file\n");
|
die_horribly(AH, modulename, "could not open TOC file: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), fh) != NULL)
|
while (fgets(buf, sizeof(buf), fh) != NULL)
|
||||||
{
|
{
|
||||||
@ -1066,7 +1068,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
|
|||||||
{
|
{
|
||||||
res = GZWRITE((void *) ptr, size, nmemb, AH->OF);
|
res = GZWRITE((void *) ptr, size, nmemb, AH->OF);
|
||||||
if (res != (nmemb * size))
|
if (res != (nmemb * size))
|
||||||
die_horribly(AH, modulename, "could not write to compressed archive\n");
|
die_horribly(AH, modulename, "could not write to output file: %s\n", strerror(errno));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
else if (AH->CustomOutPtr)
|
else if (AH->CustomOutPtr)
|
||||||
@ -1089,8 +1091,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
|
|||||||
{
|
{
|
||||||
res = fwrite((void *) ptr, size, nmemb, AH->OF);
|
res = fwrite((void *) ptr, size, nmemb, AH->OF);
|
||||||
if (res != nmemb)
|
if (res != nmemb)
|
||||||
die_horribly(AH, modulename, "could not write to output file (%lu != %lu)\n",
|
die_horribly(AH, modulename, "could not write to output file: %s\n",
|
||||||
(unsigned long) res, (unsigned long) nmemb);
|
strerror(errno));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1321,7 +1323,7 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
die_horribly(AH, modulename, "Unexpected data offset flag %d\n", offsetFlg);
|
die_horribly(AH, modulename, "unexpected data offset flag %d\n", offsetFlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1556,7 +1558,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
|
|||||||
/* Close the file */
|
/* Close the file */
|
||||||
if (wantClose)
|
if (wantClose)
|
||||||
if (fclose(fh) != 0)
|
if (fclose(fh) != 0)
|
||||||
die_horribly(AH, modulename, "could not close the input file after reading header: %s\n",
|
die_horribly(AH, modulename, "could not close input file: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
return AH->format;
|
return AH->format;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
AH->FH = stdout;
|
||||||
|
|
||||||
if (!AH->FH)
|
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);
|
ctx->hasSeek = checkSeek(AH->FH);
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
|
|||||||
else
|
else
|
||||||
AH->FH = stdin;
|
AH->FH = stdin;
|
||||||
if (!AH->FH)
|
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);
|
ctx->hasSeek = checkSeek(AH->FH);
|
||||||
|
|
||||||
@ -438,7 +438,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
|
|||||||
{
|
{
|
||||||
if ((TocIDRequired(AH, id, ropt) & REQ_DATA) != 0)
|
if ((TocIDRequired(AH, id, ropt) & REQ_DATA) != 0)
|
||||||
die_horribly(AH, modulename,
|
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");
|
" without ID on this input stream (fseek required)\n");
|
||||||
|
|
||||||
switch (blkType)
|
switch (blkType)
|
||||||
@ -540,9 +540,14 @@ _PrintData(ArchiveHandle *AH)
|
|||||||
|
|
||||||
cnt = fread(in, 1, blkLen, AH->FH);
|
cnt = fread(in, 1, blkLen, AH->FH);
|
||||||
if (cnt != blkLen)
|
if (cnt != blkLen)
|
||||||
|
{
|
||||||
|
if (feof(AH->FH))
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"could not read data block -- expected %lu, got %lu\n",
|
"could not read from input file: end of file\n");
|
||||||
(unsigned long) blkLen, (unsigned long) cnt);
|
else
|
||||||
|
die_horribly(AH, modulename,
|
||||||
|
"could not read from input file: %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
ctx->filePos += blkLen;
|
ctx->filePos += blkLen;
|
||||||
|
|
||||||
@ -663,9 +668,14 @@ _skipData(ArchiveHandle *AH)
|
|||||||
}
|
}
|
||||||
cnt = fread(in, 1, blkLen, AH->FH);
|
cnt = fread(in, 1, blkLen, AH->FH);
|
||||||
if (cnt != blkLen)
|
if (cnt != blkLen)
|
||||||
|
{
|
||||||
|
if (feof(AH->FH))
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"could not read data block -- expected %lu, got %lu\n",
|
"could not read from input file: end of file\n");
|
||||||
(unsigned long) blkLen, (unsigned long) cnt);
|
else
|
||||||
|
die_horribly(AH, modulename,
|
||||||
|
"could not read from input file: %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
ctx->filePos += blkLen;
|
ctx->filePos += blkLen;
|
||||||
|
|
||||||
@ -736,8 +746,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
|
|||||||
|
|
||||||
if (res != len)
|
if (res != len)
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"write error in _WriteBuf (%lu != %lu)\n",
|
"could not write to output file: %s\n", strerror(errno));
|
||||||
(unsigned long) res, (unsigned long) len);
|
|
||||||
|
|
||||||
ctx->filePos += res;
|
ctx->filePos += res;
|
||||||
return res;
|
return res;
|
||||||
@ -929,7 +938,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
|
|||||||
*/
|
*/
|
||||||
WriteInt(AH, zlibOutSize - zp->avail_out);
|
WriteInt(AH, zlibOutSize - zp->avail_out);
|
||||||
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (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;
|
ctx->filePos += zlibOutSize - zp->avail_out;
|
||||||
}
|
}
|
||||||
zp->next_out = (void *) out;
|
zp->next_out = (void *) out;
|
||||||
@ -943,7 +952,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
|
|||||||
{
|
{
|
||||||
WriteInt(AH, zp->avail_in);
|
WriteInt(AH, zp->avail_in);
|
||||||
if (fwrite(zp->next_in, 1, zp->avail_in, AH->FH) != 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;
|
ctx->filePos += zp->avail_in;
|
||||||
zp->avail_in = 0;
|
zp->avail_in = 0;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.27 2005/10/15 02:49:38 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.28 2006/05/22 11:21:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -243,7 +243,7 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tctx->FH == NULL)
|
if (tctx->FH == NULL)
|
||||||
die_horribly(AH, modulename, "could not open data file for output\n");
|
die_horribly(AH, modulename, "could not open output file: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
@ -287,7 +287,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (AH->FH == NULL)
|
if (AH->FH == NULL)
|
||||||
die_horribly(AH, modulename, "could not open data file for input\n");
|
die_horribly(AH, modulename, "could not open input file: %s\n", strerror(errno));
|
||||||
|
|
||||||
while ((cnt = GZREAD(buf, 1, 4095, AH->FH)) > 0)
|
while ((cnt = GZREAD(buf, 1, 4095, AH->FH)) > 0)
|
||||||
{
|
{
|
||||||
@ -411,7 +411,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
|
|||||||
|
|
||||||
res = fwrite(buf, 1, len, AH->FH);
|
res = fwrite(buf, 1, len, AH->FH);
|
||||||
if (res != len)
|
if (res != len)
|
||||||
die_horribly(AH, modulename, "write error in _WriteBuf (%lu != %lu)\n", (unsigned long) res, (unsigned long) len);
|
die_horribly(AH, modulename, "could not write to output file: %s\n", strerror(errno));
|
||||||
|
|
||||||
ctx->filePos += res;
|
ctx->filePos += res;
|
||||||
return res;
|
return res;
|
||||||
@ -508,7 +508,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tctx->FH == NULL)
|
if (tctx->FH == NULL)
|
||||||
die_horribly(AH, modulename, "could not open large object file\n");
|
die_horribly(AH, modulename, "could not open large object file for input: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.50 2006/02/12 06:11:50 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.51 2006/05/22 11:21:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -546,8 +546,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th)
|
|||||||
|
|
||||||
if (res != len)
|
if (res != len)
|
||||||
die_horribly(th->AH, modulename,
|
die_horribly(th->AH, modulename,
|
||||||
"could not write to tar member (wrote %lu, attempted %lu)\n",
|
"could not write to output file: %s\n", strerror(errno));
|
||||||
(unsigned long) res, (unsigned long) len);
|
|
||||||
|
|
||||||
th->pos += res;
|
th->pos += res;
|
||||||
return res;
|
return res;
|
||||||
@ -1035,13 +1034,12 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
res = fwrite(&buf[0], 1, cnt, th->tarFH);
|
res = fwrite(&buf[0], 1, cnt, th->tarFH);
|
||||||
if (res != cnt)
|
if (res != cnt)
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"write error appending to tar archive (wrote %lu, attempted %lu)\n",
|
"could not write to output file: %s\n", strerror(errno));
|
||||||
(unsigned long) res, (unsigned long) cnt);
|
|
||||||
len += res;
|
len += res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose(tmp) != 0) /* This *should* delete it... */
|
if (fclose(tmp) != 0) /* This *should* delete it... */
|
||||||
die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
|
die_horribly(AH, modulename, "could not close temporary file: %s\n", strerror(errno));
|
||||||
|
|
||||||
if (len != th->fileLen)
|
if (len != th->fileLen)
|
||||||
{
|
{
|
||||||
@ -1327,6 +1325,6 @@ _tarWriteHeader(TAR_MEMBER *th)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(h, 1, 512, th->tarFH) != 512)
|
if (fwrite(h, 1, 512, th->tarFH) != 512)
|
||||||
die_horribly(th->AH, modulename, "could not write tar header\n");
|
die_horribly(th->AH, modulename, "could not write to output file: %s\n", strerror(errno));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.74 2006/04/07 21:26:29 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.75 2006/05/22 11:21:54 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -38,8 +38,8 @@ int optreset;
|
|||||||
#include "pqexpbuffer.h"
|
#include "pqexpbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
/* version string we expect back from postgres */
|
/* version string we expect back from pg_dump */
|
||||||
#define PG_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
|
#define PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n"
|
||||||
|
|
||||||
|
|
||||||
static const char *progname;
|
static const char *progname;
|
||||||
@ -142,7 +142,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = find_other_exec(argv[0], "pg_dump", PG_VERSIONSTR,
|
if ((ret = find_other_exec(argv[0], "pg_dump", PGDUMP_VERSIONSTR,
|
||||||
pg_dump_bin)) < 0)
|
pg_dump_bin)) < 0)
|
||||||
{
|
{
|
||||||
char full_path[MAXPGPATH];
|
char full_path[MAXPGPATH];
|
||||||
|
Reference in New Issue
Block a user