From b4b6f27af1d196f9d6b3b8d5991216666cf2900f Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Mon, 24 Apr 2023 18:04:43 +1200
Subject: [PATCH 01/11] Assert that pgoff_t is wide enough.

On Windows, we know it's wide enough because we define it directly ourselves.
On Unix, we use off_t, which may only be 32 bits wide on some systems,
depending on compiler switches or macros.  Make absolutely certain that we are
not confused on this point with an assertion, or we'd corrupt large files.
---
 src/backend/storage/file/fd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 277a28fc13..053588a302 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -102,6 +102,9 @@
 #include "utils/resowner_private.h"
 #include "utils/varlena.h"
 
+StaticAssertDecl(sizeof(pgoff_t) >= 8,
+				 "pgoff_t not big enough to support large files");
+
 /* Define PG_FLUSH_DATA_WORKS if we have an implementation for pg_flush_data */
 #if defined(HAVE_SYNC_FILE_RANGE)
 #define PG_FLUSH_DATA_WORKS 1
-- 
2.40.1

