From 05d4cbf9b6ba708858984b01ca0fc56d59d4ec7c Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 27 Sep 2022 13:25:21 -0400 Subject: Increase width of RelFileNumbers from 32 bits to 56 bits. RelFileNumbers are now assigned using a separate counter, instead of being assigned from the OID counter. This counter never wraps around: if all 2^56 possible RelFileNumbers are used, an internal error occurs. As the cluster is limited to 2^64 total bytes of WAL, this limitation should not cause a problem in practice. If the counter were 64 bits wide rather than 56 bits wide, we would need to increase the width of the BufferTag, which might adversely impact buffer lookup performance. Also, this lets us use bigint for pg_class.relfilenode and other places where these values are exposed at the SQL level without worrying about overflow. This should remove the need to keep "tombstone" files around until the next checkpoint when relations are removed. We do that to keep RelFileNumbers from being recycled, but now that won't happen anyway. However, this patch doesn't actually change anything in this area; it just makes it possible for a future patch to do so. Dilip Kumar, based on an idea from Andres Freund, who also reviewed some earlier versions of the patch. Further review and some wordsmithing by me. Also reviewed at various points by Ashutosh Sharma, Vignesh C, Amul Sul, Álvaro Herrera, and Tom Lane. Discussion: http://postgr.es/m/CA+Tgmobp7+7kmi4gkq7Y+4AM9fTvL+O1oQ4-5gFTT+6Ng-dQ=g@mail.gmail.com --- src/include/common/relpath.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/include/common') diff --git a/src/include/common/relpath.h b/src/include/common/relpath.h index 4bbd94393c8..2d3b52fe0b8 100644 --- a/src/include/common/relpath.h +++ b/src/include/common/relpath.h @@ -22,10 +22,12 @@ /* * RelFileNumber data type identifies the specific relation file name. */ -typedef Oid RelFileNumber; -#define InvalidRelFileNumber ((RelFileNumber) InvalidOid) +typedef uint64 RelFileNumber; +#define InvalidRelFileNumber ((RelFileNumber) 0) #define RelFileNumberIsValid(relnumber) \ ((bool) ((relnumber) != InvalidRelFileNumber)) +#define atorelnumber(x) ((RelFileNumber) strtou64((x), NULL, 10)) +#define MAX_RELFILENUMBER UINT64CONST(0x00FFFFFFFFFFFFFF) /* * Name of major-version-specific tablespace subdirectories @@ -35,6 +37,7 @@ typedef Oid RelFileNumber; /* Characters to allow for an OID in a relation path */ #define OIDCHARS 10 /* max chars printed by %u */ +#define RELNUMBERCHARS 20 /* max chars printed by UINT64_FORMAT */ /* * Stuff for fork names. -- cgit v1.2.3