Re: [patch] pg_dump/pg_restore zerror() and strerror() mishap

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Kunshchikov Vladimir <Vladimir(dot)Kunshchikov(at)infotecs(dot)ru>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [patch] pg_dump/pg_restore zerror() and strerror() mishap
Date: 2017-07-25 22:02:34
Message-ID: 20170725220234.x2fprth7taeb6oc3@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kunshchikov Vladimir wrote:

> Errors should be like this:
> pg_restore: [compress_io] could not read from input file: d3/2811.dat.gz: invalid distance too far back
>
> Attached small fix for this issue.

After looking at this patch, I don't like it very much. In particular,
I don't like the way you've handled the WRITE_ERROR_EXIT macro in
pg_backup_directory.c by undef'ing the existing one and creating it
anew. The complete and correct definition should reside in one place
(pg_backup_archiver.h), instead of being split in two and being defined
differently.

Another point is that you broke the comment on the definition of struct
cfp "this is opaque to callers" by moving it to the header file
precisely with the point of making it transparent to callers. We need
some better idea there. I think it can be done by making compress_io.c
responsible of handing over the error message through some new function
(something very simple like "if compressedfp then return get_gz_error
else strerror" should suffice).

Also, I needed to rebase your patch over a recent pgindent run, though
that's a pretty small change.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2017-07-25 22:05:16 Re: pg_dump does not handle indirectly-granted permissions properly
Previous Message Peter Geoghegan 2017-07-25 22:02:04 LP_DEAD hinting and not holding on to a buffer pin on leaf page (Was: [WIP] Zipfian distribution in pgbench)