Fix case of pg_dump -Fc to an unseekable file (such as a pipe).
This was accidentally broken in commits cfa1b4a711/5e8e794e3b. It saves a line or so to call ftello unconditionally in _CloseArchive, but we have to expect that it might fail if we're not in hasSeek mode. Per report from Bernd Helmle. In passing, improve _getFilePos to print an appropriate message if ftello fails unexpectedly, rather than just a vague complaint about "ftell mismatch".
This commit is contained in:
parent
f8db074049
commit
e03485ae8a
|
@ -707,8 +707,9 @@ _CloseArchive(ArchiveHandle *AH)
|
||||||
if (AH->mode == archModeWrite)
|
if (AH->mode == archModeWrite)
|
||||||
{
|
{
|
||||||
WriteHead(AH);
|
WriteHead(AH);
|
||||||
|
/* Remember TOC's seek position for use below */
|
||||||
tpos = ftello(AH->FH);
|
tpos = ftello(AH->FH);
|
||||||
if (tpos < 0)
|
if (tpos < 0 && ctx->hasSeek)
|
||||||
exit_horribly(modulename, "could not determine seek position in archive file: %s\n",
|
exit_horribly(modulename, "could not determine seek position in archive file: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
WriteToc(AH);
|
WriteToc(AH);
|
||||||
|
@ -899,17 +900,20 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
|
||||||
|
|
||||||
if (ctx->hasSeek)
|
if (ctx->hasSeek)
|
||||||
{
|
{
|
||||||
pos = ftello(AH->FH);
|
|
||||||
if (pos != ctx->filePos)
|
|
||||||
{
|
|
||||||
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell used\n");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prior to 1.7 (pg7.3) we relied on the internally maintained
|
* Prior to 1.7 (pg7.3) we relied on the internally maintained
|
||||||
* pointer. Now we rely on ftello() always, unless the file has
|
* pointer. Now we rely on ftello() always, unless the file has been
|
||||||
* been found to not support it.
|
* found to not support it. For debugging purposes, print a warning
|
||||||
|
* if the internal pointer disagrees, so that we're more likely to
|
||||||
|
* notice if something's broken about the internal position tracking.
|
||||||
*/
|
*/
|
||||||
}
|
pos = ftello(AH->FH);
|
||||||
|
if (pos < 0)
|
||||||
|
exit_horribly(modulename, "could not determine seek position in archive file: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
|
if (pos != ctx->filePos)
|
||||||
|
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell used\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pos = ctx->filePos;
|
pos = ctx->filePos;
|
||||||
|
|
Loading…
Reference in New Issue