pgsql: Upgrade BufFile to use int64 for byte positions

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Upgrade BufFile to use int64 for byte positions
Date: 2025-12-25 23:42:51
Message-ID: E1vYuyo-002hn9-2O@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Upgrade BufFile to use int64 for byte positions

This change has the advantage of removing some weird type casts, caused
by offset calculations based on pgoff_t but saved as int (on older
branches we use off_t, which could be 4 or 8 bytes depending on the
environment). These are safe currently because capped by
MAX_PHYSICAL_FILESIZE, but we would run into problems when to make
MAX_PHYSICAL_FILESIZE larger or allow callers of these routines to use a
larger physical max size on demand.

While on it, this improves BufFileDumpBuffer() so as we do not use an
offset for "availbytes". It is not a file offset per-set, but a number
of available bytes.

This change should lead to no functional changes.

Author: 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/bde3a4616072534fd03c75f9019d5165665ed211

Modified Files
--------------
src/backend/storage/file/buffile.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-12-26 06:26:36 pgsql: doc: Remove duplicate word in ECPG description
Previous Message Michael Paquier 2025-12-25 22:54:59 pgsql: Fix typo in stat_utils.c