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.ga1...@paquier.xyz Patch, for v14, attached. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
v1-0001-Improve-server-code-to-read-files-as-part-of-a-ba.patch
Description: Binary data