40#define HEAPBLK_TO_REVMAP_BLK(pagesPerRange, heapBlk) \
41 ((heapBlk / pagesPerRange) / REVMAP_PAGE_MAXITEMS)
42#define HEAPBLK_TO_REVMAP_INDEX(pagesPerRange, heapBlk) \
43 ((heapBlk / pagesPerRange) % REVMAP_PAGE_MAXITEMS)
121 mapBlk <= revmap->rm_lastRevmapPage);
258 (
errcode(ERRCODE_INDEX_CORRUPTED),
356 iptr += revmapOffset;
382 (
errcode(ERRCODE_INDEX_CORRUPTED),
383 errmsg(
"corrupted BRIN index: inconsistent range map")));
388 (
errcode(ERRCODE_INDEX_CORRUPTED),
389 errmsg(
"corrupted BRIN index: inconsistent range map")));
450 if (targetblk <= revmap->rm_lastRevmapPage)
471 elog(
ERROR,
"revmap does not cover heap block %u", heapBlk);
475 mapBlk <= revmap->rm_lastRevmapPage);
554 if (mapBlk < nblocks)
582 (
errcode(ERRCODE_INDEX_CORRUPTED),
583 errmsg(
"unexpected page type 0x%04X in BRIN index \"%s\" block %u",
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
#define BRIN_PAGETYPE_REVMAP
#define BRIN_METAPAGE_BLKNO
#define BrinPageType(page)
#define BRIN_IS_REGULAR_PAGE(page)
void brin_evacuate_page(Relation idxRel, BlockNumber pagesPerRange, BrinRevmap *revmap, Buffer buf)
bool brin_start_evacuating_page(Relation idxRel, Buffer buf)
void brin_page_init(Page page, uint16 type)
bool brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk)
static BlockNumber revmap_extend_and_get_blkno(BrinRevmap *revmap, BlockNumber heapBlk)
void brinRevmapTerminate(BrinRevmap *revmap)
static void revmap_physical_extend(BrinRevmap *revmap)
void brinRevmapExtend(BrinRevmap *revmap, BlockNumber heapBlk)
static BlockNumber revmap_get_blkno(BrinRevmap *revmap, BlockNumber heapBlk)
BrinRevmap * brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange)
BrinTuple * brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk, Buffer *buf, OffsetNumber *off, Size *size, int mode)
void brinSetHeapBlockItemptr(Buffer buf, BlockNumber pagesPerRange, BlockNumber heapBlk, ItemPointerData tid)
#define HEAPBLK_TO_REVMAP_INDEX(pagesPerRange, heapBlk)
#define HEAPBLK_TO_REVMAP_BLK(pagesPerRange, heapBlk)
static Buffer revmap_get_buffer(BrinRevmap *revmap, BlockNumber heapBlk)
Buffer brinLockRevmapPageForUpdate(BrinRevmap *revmap, BlockNumber heapBlk)
#define XLOG_BRIN_REVMAP_EXTEND
#define SizeOfBrinRevmapExtend
#define XLOG_BRIN_DESUMMARIZE
#define SizeOfBrinDesummarize
BlockNumber BufferGetBlockNumber(Buffer buffer)
Buffer ExtendBufferedRel(BufferManagerRelation bmr, ForkNumber forkNum, BufferAccessStrategy strategy, uint32 flags)
void ReleaseBuffer(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
void MarkBufferDirty(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BUFFER_LOCK_UNLOCK
#define BUFFER_LOCK_SHARE
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
#define BUFFER_LOCK_EXCLUSIVE
static bool BufferIsValid(Buffer bufnum)
void PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum)
PageHeaderData * PageHeader
static Item PageGetItem(Page page, ItemId itemId)
static char * PageGetContents(Page page)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static void PageSetLSN(Page page, XLogRecPtr lsn)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
int errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define ItemIdGetLength(itemId)
#define ItemIdIsUsed(itemId)
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
static bool ItemPointerIsValid(const ItemPointerData *pointer)
void pfree(void *pointer)
#define START_CRIT_SECTION()
#define CHECK_FOR_INTERRUPTS()
#define END_CRIT_SECTION()
#define InvalidOffsetNumber
static PgChecksumMode mode
#define RelationGetRelationName(relation)
#define RelationNeedsWAL(relation)
static pg_noinline void Size size
BlockNumber lastRevmapPage
BlockNumber pagesPerRange
BlockNumber rm_pagesPerRange
BlockNumber rm_lastRevmapPage
ItemPointerData rm_tids[1]
BlockNumber pagesPerRange
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const char *data, uint32 len)
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
void XLogBeginInsert(void)