diff options
| author | Robert Haas | 2022-08-24 19:50:48 +0000 |
|---|---|---|
| committer | Robert Haas | 2022-08-24 19:50:48 +0000 |
| commit | 82ac34db2036ec5b3cb32c9180f40549aa790dc2 (patch) | |
| tree | 19385f9f12f528216ece87e22c29a487a0d0dc69 /src/include | |
| parent | 396d348b046c6b7e5dc83158c4c1df1377a1d2ef (diff) | |
Include RelFileLocator fields individually in BufferTag.
This is preparatory work for a project to increase the number of bits
in a RelFileNumber from 32 to 56.
Along the way, introduce static inline accessor functions for a couple
of BufferTag fields.
Dilip Kumar, reviewed by me. The overall patch series has also had
review at various times from Andres Freund, Ashutosh Sharma, Hannu
Krosing, Vignesh C, Álvaro Herrera, and Tom Lane.
Discussion: http://postgr.es/m/CAFiTN-trubju5YbWAq-BSpZ90-Z6xCVBQE8BVqXqANOZAF1Znw@mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/storage/buf_internals.h | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index 72466551d71..406db6be783 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -90,18 +90,51 @@ */ typedef struct buftag { - RelFileLocator rlocator; /* physical relation identifier */ - ForkNumber forkNum; + Oid spcOid; /* tablespace oid */ + Oid dbOid; /* database oid */ + RelFileNumber relNumber; /* relation file number */ + ForkNumber forkNum; /* fork number */ BlockNumber blockNum; /* blknum relative to begin of reln */ } BufferTag; +static inline RelFileNumber +BufTagGetRelNumber(const BufferTag *tag) +{ + return tag->relNumber; +} + +static inline ForkNumber +BufTagGetForkNum(const BufferTag *tag) +{ + return tag->forkNum; +} + +static inline void +BufTagSetRelForkDetails(BufferTag *tag, RelFileNumber relnumber, + ForkNumber forknum) +{ + tag->relNumber = relnumber; + tag->forkNum = forknum; +} + +static inline RelFileLocator +BufTagGetRelFileLocator(const BufferTag *tag) +{ + RelFileLocator rlocator; + + rlocator.spcOid = tag->spcOid; + rlocator.dbOid = tag->dbOid; + rlocator.relNumber = BufTagGetRelNumber(tag); + + return rlocator; +} + static inline void ClearBufferTag(BufferTag *tag) { - tag->rlocator.spcOid = InvalidOid; - tag->rlocator.dbOid = InvalidOid; - tag->rlocator.relNumber = InvalidRelFileNumber; - tag->forkNum = InvalidForkNumber; + tag->spcOid = InvalidOid; + tag->dbOid = InvalidOid; + BufTagSetRelForkDetails(tag, InvalidRelFileNumber, InvalidForkNumber); tag->blockNum = InvalidBlockNumber; } @@ -109,19 +142,32 @@ static inline void InitBufferTag(BufferTag *tag, const RelFileLocator *rlocator, ForkNumber forkNum, BlockNumber blockNum) { - tag->rlocator = *rlocator; - tag->forkNum = forkNum; + tag->spcOid = rlocator->spcOid; + tag->dbOid = rlocator->dbOid; + BufTagSetRelForkDetails(tag, rlocator->relNumber, forkNum); tag->blockNum = blockNum; } static inline bool BufferTagsEqual(const BufferTag *tag1, const BufferTag *tag2) { - return RelFileLocatorEquals(tag1->rlocator, tag2->rlocator) && + return (tag1->spcOid == tag2->spcOid) && + (tag1->dbOid == tag2->dbOid) && + (tag1->relNumber == tag2->relNumber) && (tag1->blockNum == tag2->blockNum) && (tag1->forkNum == tag2->forkNum); } +static inline bool +BufTagMatchesRelFileLocator(const BufferTag *tag, + const RelFileLocator *rlocator) +{ + return (tag->spcOid == rlocator->spcOid) && + (tag->dbOid == rlocator->dbOid) && + (BufTagGetRelNumber(tag) == rlocator->relNumber); +} + + /* * The shared buffer mapping table is partitioned to reduce contention. * To determine which partition lock a given tag requires, compute the tag's |
