Commit 8a12aac3 authored by Tom Lane's avatar Tom Lane

Minor style policing for error messages in pg_dump tar code. Notably, change

"dumping data out of order is not supported" to "restoring data out of order
is not supported", because you get that error during pg_restore not pg_dump.
Also fix some comments that didn't look so good after being pgindented as
perhaps they did originally.
parent a5480314
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.67 2010/01/07 04:53:35 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.68 2010/02/23 16:55:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -211,8 +211,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -211,8 +211,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
* positioning. * positioning.
*/ */
if (AH->compression != 0) if (AH->compression != 0)
die_horribly(NULL, modulename, "compression not supported by tar output format\n"); die_horribly(NULL, modulename, "compression is not supported by tar archive format\n");
} }
else else
{ /* Read Mode */ { /* Read Mode */
...@@ -348,12 +347,19 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -348,12 +347,19 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
tm = _tarPositionTo(AH, filename); tm = _tarPositionTo(AH, filename);
if (!tm) /* Not found */ if (!tm) /* Not found */
{ {
if (filename) /* Couldn't find the requested file. Future: if (filename)
* DO SEEK(0) and retry. */ {
die_horribly(AH, modulename, "could not find file %s in archive\n", filename); /*
* Couldn't find the requested file. Future:
* do SEEK(0) and retry.
*/
die_horribly(AH, modulename, "could not find file \"%s\" in archive\n", filename);
}
else else
/* Any file OK, non left, so return NULL */ {
/* Any file OK, none left, so return NULL */
return NULL; return NULL;
}
} }
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
...@@ -361,12 +367,11 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -361,12 +367,11 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
if (AH->compression == 0) if (AH->compression == 0)
tm->nFH = ctx->tarFH; tm->nFH = ctx->tarFH;
else else
die_horribly(AH, modulename, "compression support is disabled in this format\n"); die_horribly(AH, modulename, "compression is not supported by tar archive format\n");
/* tm->zFH = gzdopen(dup(fileno(ctx->tarFH)), "rb"); */ /* tm->zFH = gzdopen(dup(fileno(ctx->tarFH)), "rb"); */
#else #else
tm->nFH = ctx->tarFH; tm->nFH = ctx->tarFH;
#endif #endif
} }
else else
{ {
...@@ -414,7 +419,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -414,7 +419,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
tm->zFH = gzdopen(dup(fileno(tm->tmpFH)), fmode); tm->zFH = gzdopen(dup(fileno(tm->tmpFH)), fmode);
if (tm->zFH == NULL) if (tm->zFH == NULL)
die_horribly(AH, modulename, "could not open temporary file\n"); die_horribly(AH, modulename, "could not open temporary file\n");
} }
else else
tm->nFH = tm->tmpFH; tm->nFH = tm->tmpFH;
...@@ -431,7 +435,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -431,7 +435,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
tm->tarFH = ctx->tarFH; tm->tarFH = ctx->tarFH;
return tm; return tm;
} }
static void static void
...@@ -1150,20 +1153,19 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1150,20 +1153,19 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
ahlog(AH, 4, "now at file position %s\n", buf); ahlog(AH, 4, "now at file position %s\n", buf);
} }
/* We are at the start of the file. or at the next member */ /* We are at the start of the file, or at the next member */
/* Get the header */ /* Get the header */
if (!_tarGetHeader(AH, th)) if (!_tarGetHeader(AH, th))
{ {
if (filename) if (filename)
die_horribly(AH, modulename, "could not find header for file %s in tar archive\n", filename); die_horribly(AH, modulename, "could not find header for file \"%s\" in tar archive\n", filename);
else else
{
/* /*
* We're just scanning the archibe for the next file, so return * We're just scanning the archive for the next file, so return
* null * null
*/ */
{
free(th); free(th);
return NULL; return NULL;
} }
...@@ -1175,8 +1177,8 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1175,8 +1177,8 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
id = atoi(th->targetFile); id = atoi(th->targetFile);
if ((TocIDRequired(AH, id, AH->ropt) & REQ_DATA) != 0) if ((TocIDRequired(AH, id, AH->ropt) & REQ_DATA) != 0)
die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: " die_horribly(AH, modulename, "restoring data out of order is not supported in this archive format: "
"%s is required, but comes before %s in the archive file.\n", "\"%s\" is required, but comes before \"%s\" in the archive file.\n",
th->targetFile, filename); th->targetFile, filename);
/* Header doesn't match, so read to next header */ /* Header doesn't match, so read to next header */
...@@ -1187,8 +1189,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1187,8 +1189,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
_tarReadRaw(AH, &header[0], 512, NULL, ctx->tarFH); _tarReadRaw(AH, &header[0], 512, NULL, ctx->tarFH);
if (!_tarGetHeader(AH, th)) if (!_tarGetHeader(AH, th))
die_horribly(AH, modulename, "could not find header for file %s in tar archive\n", filename); die_horribly(AH, modulename, "could not find header for file \"%s\" in tar archive\n", filename);
} }
ctx->tarNextMember = ctx->tarFHpos + ((th->fileLen + 511) & ~511); ctx->tarNextMember = ctx->tarFHpos + ((th->fileLen + 511) & ~511);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment