git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e8e794)
Further pg_dump / ftello improvements
Sun, 9 Feb 2014 23:28:14 +0000 (18:28 -0500)
Sun, 9 Feb 2014 23:28:14 +0000 (18:28 -0500)
Make ftello error-checking consistent to all calls and remove a
bit of ftello-related code which has been #if 0'd out since 2001.

Note that we are not concerned with the ftello() call under
snprintf() failing as it is just building a string to call
exit_horribly() with; printing -1 in such a case is fine.


diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 8ea40ea7b76b8bea20f253d597899c34b004b85c..2b36e45533586589ed3dac8cad57054fffbb764f 100644 (file)
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -3347,9 +3347,8 @@ checkSeek(FILE *fp)
#endif
/* Check that ftello works on this file */
- errno = 0;
tpos = ftello(fp);
- if (errno)
+ if (tpos < 0)
return false;
/*
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 06005ae8682a5cb55076b117603b7dd8a572e83b..3bdbf868189aacada76f5a842825c51c83f8b932 100644 (file)
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -1068,6 +1068,9 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
*/
fseeko(tmp, 0, SEEK_END);
th->fileLen = ftello(tmp);
+ if (th->fileLen < 0)
+ exit_horribly(modulename, "could not determine seek position in file: %s\n",
+ strerror(errno));
fseeko(tmp, 0, SEEK_SET);
/*
@@ -1212,20 +1215,6 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
while (!gotBlock)
{
-#if 0
- if (ftello(ctx->tarFH) != ctx->tarFHpos)
- {
- char buf1[100],
- buf2[100];
-
- snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ftello(ctx->tarFH));
- snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ftello(ctx->tarFHpos));
- exit_horribly(modulename,
- "mismatch in actual vs. predicted file position (%s vs. %s)\n",
- buf1, buf2);
- }
-#endif
-
/* Save the pos for reporting purposes */
hPos = ctx->tarFHpos;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /