aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_tar.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-08-02 18:26:26 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-08-02 18:26:59 -0400
commit4d57e83816778c6f61ea35c697f937a6f9c3c3de (patch)
treeb1cebe54a1823f771d2fe00aa52499e360272ebb /src/bin/pg_dump/pg_backup_tar.c
parent80215156f9a10dfcacfcef15be35ebb0d79300b5 (diff)
downloadpostgresql-4d57e83816778c6f61ea35c697f937a6f9c3c3de.tar.gz
postgresql-4d57e83816778c6f61ea35c697f937a6f9c3c3de.zip
Fix pg_dump's errno checking for zlib I/O
Some error reports were reporting strerror(errno), which for some error conditions coming from zlib are wrong, resulting in confusing reports such as pg_restore: [compress_io] could not read from input file: Success which makes no sense. To correctly extract the error message we need to use gzerror(), so let's do that. This isn't as comprehensive or as neat as I would like, but at least it should improve things in many common cases. The zlib abstraction in compress_io does not seem to be applied consistently enough; we could perhaps improve that, but it seems master-only material, not a bug fix for back-patching. This problem goes back all the way, but I decided to apply back to 9.4 only, because older branches don't contain commit 14ea89366 which this change depends on. Authors: Vladimir Kunschikov, Álvaro Herrera Discussion: https://postgr.es/m/1498120508308.9826@infotecs.ru
Diffstat (limited to 'src/bin/pg_dump/pg_backup_tar.c')
-rw-r--r--src/bin/pg_dump/pg_backup_tar.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index f839712945f..3c41d40a938 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -555,8 +555,14 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, size_t len, TAR_MEMBER *th, FILE *fh)
{
res = GZREAD(&((char *) buf)[used], 1, len, th->zFH);
if (res != len && !GZEOF(th->zFH))
+ {
+ int errnum;
+ const char *errmsg = gzerror(th->zFH, &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
{