improving basebackup.c's file-reading code - Mailing list pgsql-hackers

From Robert Haas
Subject improving basebackup.c's file-reading code
Date
Msg-id CA+TgmobBw-3573vMosGj06r72ajHsYeKtksT_oTxH8XvTL7DxA@mail.gmail.com
Whole thread Raw
Responses Re: improving basebackup.c's file-reading code  (Hamid Akhtar <hamid.akhtar@gmail.com>)
List pgsql-hackers
Hi,

basebackup.c's code to read from files uses fread() and friends. This
is not great, because it's not documented to set errno. See commit
286af0ce12117bc673b97df6228d1a666594d247 and related discussion. It
seems like a better idea would be to use pg_pgread(), which not only
does set errno, but also lets us eliminate a bit of code that uses
fseek().

There are a couple of other things here that can also be improved. One
is that it seems like a good idea to set a wait event while doing I/O
here, as we do elsewhere. Another is that it seems like a good idea to
report short reads in a non-confusing, non-wrong sort of way. I here
adopted the convention previously mentioned in
http://postgr.es/m/20200128020303.GA1552@paquier.xyz

Patch, for v14, attached.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: weird hash plan cost, starting with pg10
Next
From: "Jonah H. Harris"
Date:
Subject: Proposing WITH ITERATIVE