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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Switch buffile.c/h to use pgoff_t instead of off_t
Date: 2025-12-22 22:46:29
Message-ID: E1vXofc-0029z3-1W@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)evan(dot)chao(at)gmail(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2025-12-23 00:42:14 pgsql: doc: add "DO" to "ON CONFLICT" in CREATE VIEW text
Previous Message Masahiko Sawada 2025-12-22 22:29:03 pgsql: psql: Improve tab completion for COPY option lists.