1/*-------------------------------------------------------------------------
4 * Bloom VACUUM functions.
6 * Copyright (c) 2016-2025, PostgreSQL Global Development Group
9 * contrib/bloom/blvacuum.c
11 *-------------------------------------------------------------------------
23 * Bulk deletion of all index entries pointing to a set of heap tuples.
24 * The set of target tuples is specified via a callback routine that tells
25 * whether any given heap tuple (identified by ItemPointer) is being deleted.
27 * Result: a palloc'd struct containing statistical info for VACUUM displays.
50 * Iterate over the pages. We don't care about concurrently added pages,
51 * they can't contain tuples to delete.
69 /* Ignore empty/deleted pages until blvacuumcleanup() */
78 * Iterate over the tuples. itup points to current tuple being
79 * scanned, itupPtr points to where to save next non-deleted tuple.
84 while (itup < itupEnd)
86 /* Do we have to delete this tuple? */
89 /* Yes; adjust count of tuples that will be left on page */
95 /* No; copy it to itupPtr++, but skip copy if not needed */
98 state.sizeOfBloomTuple);
105 /* Assert that we counted correctly */
110 * Add page to new notFullPage list if we will not mark page as
111 * deleted and there is free space on it
116 notFullPage[countPage++] = blkno;
118 /* Did we delete something? */
121 /* Is it empty page now? */
124 /* Adjust pd_lower */
126 /* Finish WAL-logging */
131 /* Didn't change anything: abort WAL-logging */
138 * Update the metapage's notFullPage list with whatever we found. Our
139 * info could already be out of date at this point, but blinsert() will
151 metaData->
nEnd = countPage;
160 * Post-VACUUM cleanup.
162 * Result: a palloc'd struct containing statistical info for VACUUM displays.
178 * Iterate over the pages: insert deleted pages into FSM and collect
#define BloomPageGetOpaque(page)
#define BloomPageGetFreeSpace(state, page)
#define BloomPageGetMeta(page)
BlockNumber FreeBlockNumberArray[MAXALIGN_DOWN(BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(BloomPageOpaqueData)) - MAXALIGN(sizeof(uint16) *2+sizeof(uint32)+sizeof(BloomOptions)))/sizeof(BlockNumber)]
#define BloomPageGetMaxOffset(page)
#define BloomPageGetTuple(state, page, offset)
#define BloomPageSetDeleted(page)
#define BloomPageGetNextTuple(state, tuple)
#define BloomPageIsDeleted(page)
void initBloomState(BloomState *state, Relation index)
#define BLOOM_METAPAGE_BLKNO
IndexBulkDeleteResult * blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
IndexBulkDeleteResult * blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BUFFER_LOCK_SHARE
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
#define BUFFER_LOCK_EXCLUSIVE
PageHeaderData * PageHeader
static bool PageIsNew(const PageData *page)
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer, int flags)
GenericXLogState * GenericXLogStart(Relation relation)
XLogRecPtr GenericXLogFinish(GenericXLogState *state)
void GenericXLogAbort(GenericXLogState *state)
Assert(PointerIsAligned(start, uint64))
void IndexFreeSpaceMapVacuum(Relation rel)
void RecordFreeIndexPage(Relation rel, BlockNumber freeBlock)
void * palloc0(Size size)
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
FreeBlockNumberArray notFullPage
BufferAccessStrategy strategy
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
void vacuum_delay_point(bool is_analyze)