From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | improving basebackup.c's file-reading code |
Date: | 2020-04-27 16:33:55 |
Message-ID: | CA+TgmobBw-3573vMosGj06r72ajHsYeKtksT_oTxH8XvTL7DxA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
v1-0001-Improve-server-code-to-read-files-as-part-of-a-ba.patch | application/octet-stream | 10.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Jonah H. Harris | 2020-04-27 16:52:48 | Proposing WITH ITERATIVE |
Previous Message | Justin Pryzby | 2020-04-27 16:29:58 | Re: weird hash plan cost, starting with pg10 |