mirror of
https://github.com/postgres/postgres.git
synced 2025-11-26 23:43:30 +03:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user