pgsql: Don't cast pgoff_t to possibly 32-bit types for output

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't cast pgoff_t to possibly 32-bit types for output
Date: 2026-07-07 09:50:09
Message-ID: E1wh2RN-0000dd-14@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't cast pgoff_t to possibly 32-bit types for output

pgoff_t is most likely a 64-bit integer, so casting it to a 32-bit
type for output could lose data. In the cases addressed here, the
files cannot actually get that large, so this is only cosmetic and to
set better examples for the future. (Similar issues that could have
actual practical impact were addressed separately in commit
e8f851d6172.)

In one case, the 32-bit size is baked into the protocol, so here we
add an elog and document this discrepancy.

Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/20ce62fa-47fc-457b-b504-12f3c1651726%40eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/04fc2564fbbabe97cadbf782e8d40b8e3f7b22a5

Modified Files
--------------
src/backend/access/heap/rewriteheap.c | 4 ++--
src/backend/backup/walsummary.c | 4 ++--
src/backend/replication/walsender.c | 6 ++++++
src/backend/storage/file/fd.c | 4 ++--
src/bin/pg_upgrade/slru_io.c | 4 ++--
5 files changed, 14 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-07-07 09:56:16 pgsql: Print off_t/pgoff_t consistently as %lld
Previous Message Etsuro Fujita 2026-07-07 09:43:13 pgsql: postgres_fdw: Report ANALYZE to pgstats after importing statisti