Switch buffile.c/h to use pgoff_t instead of off_t master github/master
authorMichael Paquier <[email protected]>
Mon, 22 Dec 2025 22:41:34 +0000 (07:41 +0900)
committerMichael Paquier <[email protected]>
Mon, 22 Dec 2025 22:41:34 +0000 (07:41 +0900)
commite5f3839af685c303d8ebcc1ea0d407c124372931
treeb2e95bbc379d5abcd12e71ca528c2e4440cceb2e
parentc6a7d3bab493e8d589f24d239db00ce5c2934178
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 <[email protected]>
Discussion: https://postgr.es/m/[email protected]
src/backend/replication/logical/worker.c
src/backend/storage/file/buffile.c
src/backend/utils/sort/tuplestore.c
src/include/storage/buffile.h