pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Switch buffile.c/h to use pgoff_t instead of off_t
Date: Mon, 22 Dec 2025 22:46:29 +0000
Message-ID: <E1vXofc-0029z3-1W@gemulon.postgresql.org> (raw)

Switch buffile.c/h to use pgoff_t instead of off_t

off_t was previously used for offsets, which is 4 bytes on Windows,
hence limiting the backend code to a hard limit for files longer than
2GB.  This leads to some simplification in these files, removing some
casts based on long, also 4 bytes on Windows.

This commit removes one comment introduced in db3c4c3a2d98, not relevant
anymore as pgoff_t is a safe 8-byte alternative on Windows.

This change is surprisingly not invasive, as the callers of
BufFileTell(), BufFileSeek() and BufFileTruncateFileSet() (worker.c,
tuplestore.c, etc.) track offsets in local structures that just to
switch from off_t to pgoff_t for the most part.

The file is still relying on a maximum file size of
MAX_PHYSICAL_FILESIZE (1GB).  This change allows the code to make this
maximum potentially larger in the future, or larger on a per-demand
basis.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aUStrqoOCDRFAq1M@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e5f3839af685c303d8ebcc1ea0d407c124372931

Modified Files
--------------
src/backend/replication/logical/worker.c |  8 ++++----
src/backend/storage/file/buffile.c       | 23 +++++++++++------------
src/backend/utils/sort/tuplestore.c      | 12 ++++++------
src/include/storage/buffile.h            |  6 +++---
4 files changed, 24 insertions(+), 25 deletions(-)



Message-ID: <E1vXofc-0029z3-1W@gemulon.postgresql.org>
Permalink:  ../E1vXofc-0029z3-1W@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vXofc-0029z3-1W@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Switch buffile.c/h to use pgoff_t instead of off_t
  In-Reply-To: <E1vXofc-0029z3-1W@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox