gzclose don't set properly the errno in pg_restore - Mailing list pgsql-hackers

From Fabrízio de Royes Mello
Subject gzclose don't set properly the errno in pg_restore
Date
Msg-id CAFcNs+os5ExGvXMBrBBzzuJJamoHt5-zdJdxX39nkVG0KUxwsw@mail.gmail.com
Whole thread
Responses Re: gzclose don't set properly the errno in pg_restore
List pgsql-hackers
Hi all,

I'm facing with a strange error message during a failed pg_restore:

pg_restore: processing data for table "historicopesquisaitem"
pg_restore: [directory archiver] could not close data file: Success

I got this error trying to restore from a directory dump file.

Looking at the pg_restore code seems that "gzclose" didn't set the 'errno' because I got a Z_BUF_ERROR [1] from "cfclose" return and the "errno" still 0 (zero).

412     if (cfclose(cfp) !=0)
413         exit_horribly(modulename, "could not close data file: %s\n",
414                       strerror(errno));

Should we set the errno using the gzclose return code or just add some check to "strerror" the "errno" or the "gzclose return code" if they are different?

Thoughts?


[1] http://www.zlib.net/manual.html

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Proposal: "Causal reads" mode for load balancing reads without stale data
Next
From: Joe Conway
Date:
Subject: Re: Badly designed error reporting code in controldata_utils.c