Re: Switch buffile.c/h to use pgoff_t - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Switch buffile.c/h to use pgoff_t
Date
Msg-id aUx6TMczfmwyv_h3@paquier.xyz
Whole thread Raw
In response to Re: Switch buffile.c/h to use pgoff_t  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: Switch buffile.c/h to use pgoff_t
Re: Switch buffile.c/h to use pgoff_t
List pgsql-hackers
On Wed, Dec 24, 2025 at 05:01:57PM +0800, Chao Li wrote:
> Make sense, bytestowrite is not a file offset. So, in the current code,
> availbytes is not a file offset either, but it is defined as pgoff_t, which
> has the same confusion, right? Also bytestowrite is casted to pgoff_t, it's
> the same confusion again.

Yeah, actually this suggestion makes more sense.  availbytes is a
computation made of a maximal size and an offset, so defining it as an
offset from the start is kind of weird.

Now I don't think that your suggested set of changes could become more
consistent with a few more changes.  For example, what about pos and
nbytes in BufFile?  While ssize_t is more consistent with FileRead()
and FileWrite(), this code is written to care about signedness while
ssize_t has a stricter range per posix, hence could int64 be a better
choice for the whole interface?  int64 is already what we use for
BufFileSize(), which is due to the limit of MAX_PHYSICAL_FILESIZE of
course.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Docs: Standardize "cannot" usage in SGML source
Next
From: Michael Paquier
Date:
Subject: Re: Switch buffile.c/h to use pgoff_t