| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Bryan Green <dbryan(dot)green(at)gmail(dot)com> |
| Subject: | Re: Switch buffile.c/h to use pgoff_t |
| Date: | 2025-12-24 09:01:57 |
| Message-ID: | CAEoWx2=bkpLbd2=sX6rVsw1OT8FNnp2O+LdpkTbdgbOev-9vgg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Dec 24, 2025 at 2:15 PM Michael Paquier <michael(at)paquier(dot)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.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-buffile-use-ssize_t-for-bytestowrite-in-BufFileDu.patch | application/octet-stream | 1.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2025-12-24 09:06:50 | Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE |
| Previous Message | Michael Paquier | 2025-12-24 08:58:20 | Re: Orphaned records in pg_replication_origin_status after subscription drop |