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

From Chao Li
Subject Re: Switch buffile.c/h to use pgoff_t
Date
Msg-id CAEoWx2=bkpLbd2=sX6rVsw1OT8FNnp2O+LdpkTbdgbOev-9vgg@mail.gmail.com
Whole thread Raw
In response to Re: Switch buffile.c/h to use pgoff_t  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Switch buffile.c/h to use pgoff_t
List pgsql-hackers

On Wed, Dec 24, 2025 at 2:15 PM Michael Paquier <michael@paquier.xyz> wrote:
On Tue, Dec 23, 2025 at 10:59:45AM +0800, Chao Li wrote:
> I’ve attached a small patch along these lines. It compiles without
> warnings, and "make check" passes on my side. What do you think?

I don't think it is right.  bytestowrite is not a file offset, and the
code has been using an int due to BufFile->nbytes.  This leads to a
more confusing result.
--
Michael

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.

How about using "ssize_t" for both bytestowrite and availbytes? It's still signed, broader than int, and the odd type casts are eliminated. 

In win32_port.h:
```
#ifndef _WIN64
typedef long ssize_t;
#else
typedef __int64 ssize_t;
#endif
```

Best regards,
==
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Orphaned records in pg_replication_origin_status after subscription drop
Next
From: Chao Li
Date:
Subject: Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE