Re: Add BufFileRead variants with short read and EOF detection

Amit Kapila <amit.kapila16@gmail.com>

From: Amit Kapila <amit.kapila16@gmail.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-01-02T12:13:29Z
Lists: pgsql-hackers
On Wed, Dec 28, 2022 at 4:17 PM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:
>
> Most callers of BufFileRead() want to check whether they read the full
> specified length.  Checking this at every call site is very tedious.
> This patch provides additional variants BufFileReadExact() and
> BufFileReadMaybeEOF() that include the length checks.
>
> I considered changing BufFileRead() itself, but this function is also
> used in extensions, and so changing the behavior like this would create
> a lot of problems there.  The new names are analogous to the existing
> LogicalTapeReadExact().
>

+1 for the new APIs. I have noticed that some of the existing places
use %m and the file path in messages which are not used in the new
common function.

-- 
With Regards,
Amit Kapila.



Commits

  1. Add BufFileRead variants with short read and EOF detection

  2. Fix some BufFileRead() error reporting

  3. Push lpp variable closer to usage in heapgetpage()

  4. Fix buffile.c error handling.