aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/compress_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/compress_io.c')
-rw-r--r--src/bin/pg_dump/compress_io.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/bin/pg_dump/compress_io.c b/src/bin/pg_dump/compress_io.c
index 991fe11e8a6..e94f7d32743 100644
--- a/src/bin/pg_dump/compress_io.c
+++ b/src/bin/pg_dump/compress_io.c
@@ -592,8 +592,14 @@ cfread(void *ptr, int size, cfp *fp)
{
ret = gzread(fp->compressedfp, ptr, size);
if (ret != size && !gzeof(fp->compressedfp))
+ {
+ int errnum;
+ const char *errmsg = gzerror(fp->compressedfp, &errnum);
+
exit_horribly(modulename,
- "could not read from input file: %s\n", strerror(errno));
+ "could not read from input file: %s\n",
+ errnum == Z_ERRNO ? strerror(errno) : errmsg);
+ }
}
else
#endif
@@ -695,6 +701,22 @@ cfeof(cfp *fp)
return feof(fp->uncompressedfp);
}
+const char *
+get_cfp_error(cfp *fp)
+{
+#ifdef HAVE_LIBZ
+ if (fp->compressedfp)
+ {
+ int errnum;
+ const char *errmsg = gzerror(fp->compressedfp, &errnum);
+
+ if (errnum != Z_ERRNO)
+ return errmsg;
+ }
+#endif
+ return strerror(errno);
+}
+
#ifdef HAVE_LIBZ
static int
hasSuffix(const char *filename, const char *suffix)