180 (
char *) metapage,
true);
210 itup->
t_tid = *ht_ctid;
212 result =
_bt_doinsert(rel, itup, checkUnique, indexUnchanged, heapRel);
402 ScanKey orderbys,
int norderbys)
518 if (so->numArrayKeys)
608 BTParallelScanDesc btscan;
651 bool exit_loop =
false;
654 BTParallelScanDesc btscan;
659 parallel_scan->ps_offset);
664 pageStatus = btscan->btps_pageStatus;
686 *pageno = btscan->btps_scanPage;
708 BTParallelScanDesc btscan;
732 BTParallelScanDesc btscan;
733 bool status_changed =
false;
736 if (parallel_scan == NULL)
740 parallel_scan->ps_offset);
752 status_changed =
true;
773 BTParallelScanDesc btscan;
776 parallel_scan->ps_offset);
784 btscan->btps_arrayKeyCount++;
838 float8 cleanup_scale_factor;
839 float8 prev_num_heap_tuples;
849 cleanup_scale_factor = (relopts &&
855 if (cleanup_scale_factor <= 0 ||
857 prev_num_heap_tuples <= 0 ||
859 prev_num_heap_tuples >= cleanup_scale_factor)
891 btvacuumscan(info, stats, callback, callback_state, cycleid);
987 vstate.
stats = stats;
1039 if (scanblkno >= num_pages)
1042 for (; scanblkno < num_pages; scanblkno++)
1106 bool attempt_pagedel;
1117 attempt_pagedel =
false;
1140 Assert(blkno <= scanblkno);
1141 if (blkno != scanblkno)
1163 (
errcode(ERRCODE_INDEX_CORRUPTED),
1164 errmsg_internal(
"right sibling %u of scanblkno %u unexpectedly in an inconsistent state in index \"%s\"",
1218 attempt_pagedel =
true;
1270 for (offnum = minoff;
1305 deletable[ndeletable++] = offnum;
1319 if (vacposting == NULL)
1327 else if (nremaining > 0)
1337 updatable[nupdatable++] = vacposting;
1348 deletable[ndeletable++] = offnum;
1353 nhtidslive += nremaining;
1362 if (ndeletable > 0 || nupdatable > 0)
1364 Assert(nhtidsdead >= ndeletable + nupdatable);
1373 for (
int i = 0;
i < nupdatable;
i++)
1409 if (minoff > maxoff)
1410 attempt_pagedel = (blkno == scanblkno);
1416 Assert(!attempt_pagedel || nhtidslive == 0);
1419 if (attempt_pagedel)
1432 Assert(blkno == scanblkno);
1441 if (backtrack_to !=
P_NONE)
1443 blkno = backtrack_to;
1468 for (
int i = 0;
i < nitem;
i++)
1475 else if (vacposting == NULL)
1487 vacposting->
itup = posting;
ambeginscan_function ambeginscan
uint8 amparallelvacuumoptions
#define PG_RETURN_POINTER(x)
ambulkdelete_function ambulkdelete
bool _bt_advance_array_keys(IndexScanDesc scan, ScanDirection dir)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
MemoryContext pagedelcontext
void btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
static bool BTreeTupleIsPivot(IndexTuple itup)
static bool _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
amgettuple_function amgettuple
struct BTParallelScanDescData BTParallelScanDescData
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
void _bt_parallel_done(IndexScanDesc scan)
#define RelationGetDescr(relation)
void _bt_start_array_keys(IndexScanDesc scan, ScanDirection dir)
Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access)
MemoryContext arrayContext
amproperty_function amproperty
char * btbuildphasename(int64 phasenum)
#define PointerGetDatum(X)
static ItemPointer BTreeTupleGetPosting(IndexTuple posting)
struct SMgrRelationData * rd_smgr
void pgstat_progress_update_param(int index, int64 val)
void _bt_delitems_vacuum(Relation rel, Buffer buf, OffsetNumber *deletable, int ndeletable, BTVacuumPosting *updatable, int nupdatable)
OffsetNumber updatedoffset
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
#define SpinLockInit(lock)
#define P_FIRSTDATAKEY(opaque)
#define RELATION_IS_LOCAL(relation)
struct TupleDescData * xs_itupdesc
IndexBulkDeleteCallback callback
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
amparallelrescan_function amparallelrescan
static BTVacuumPosting btreevacuumposting(BTVacState *vstate, IndexTuple posting, OffsetNumber updatedoffset, int *nremaining)
union BTPageOpaqueData::@46 btpo
BufferAccessStrategy strategy
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static void btvacuumpage(BTVacState *vstate, BlockNumber scanblkno)
void ConditionVariableBroadcast(ConditionVariable *cv)
int errcode(int sqlerrcode)
double vacuum_cleanup_index_scale_factor
#define BTScanPosIsValid(scanpos)
void _bt_initmetapage(Page page, BlockNumber rootbknum, uint32 level, bool allequalimage)
void MemoryContextReset(MemoryContext context)
void _bt_end_vacuum_callback(int code, Datum arg)
IndexScanDesc btbeginscan(Relation rel, int nkeys, int norderbys)
void _bt_update_meta_cleanup_info(Relation rel, TransactionId oldestBtpoXact, float8 numHeapTuples)
aminsert_function aminsert
static void btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state, BTCycleId cycleid)
#define MaxTIDsPerBTreePage
struct BTParallelScanDescData * BTParallelScanDesc
bool _bt_page_recyclable(Page page)
#define PageGetMaxOffsetNumber(page)
amvalidate_function amvalidate
Size btestimateparallelscan(void)
BTPageOpaqueData * BTPageOpaque
bool _bt_first(IndexScanDesc scan, ScanDirection dir)
bool btvalidate(Oid opclassoid)
IndexTuple index_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
void _bt_restore_array_keys(IndexScanDesc scan)
void btbuildempty(Relation index)
#define SpinLockAcquire(lock)
void ConditionVariableInit(ConditionVariable *cv)
#define PG_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
void _bt_killitems(IndexScanDesc scan)
float8 vacuum_cleanup_index_scale_factor
void pfree(void *pointer)
IndexBulkDeleteResult * btvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
void ConditionVariableCancelSleep(void)
amgetbitmap_function amgetbitmap
void _bt_checkpage(Relation rel, Buffer buf)
#define P_ISHALFDEAD(opaque)
amoptions_function amoptions
int64 btgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
IndexBuildResult * btbuild(Relation heap, Relation index, IndexInfo *indexInfo)
BTScanOpaqueData * BTScanOpaque
void btadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
void ConditionVariableSignal(ConditionVariable *cv)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
void btendscan(IndexScanDesc scan)
#define ALLOCSET_DEFAULT_SIZES
RelFileNodeBackend smgr_rnode
amcostestimate_function amcostestimate
uint32 _bt_pagedel(Relation rel, Buffer leafbuf, TransactionId *oldestBtpoXact)
void btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
ConditionVariable btps_cv
ItemPointerData xs_heaptid
void _bt_end_vacuum(Relation rel)
amvacuumcleanup_function amvacuumcleanup
amendscan_function amendscan
void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer, bool skipFsync)
#define BTScanPosIsPinned(scanpos)
IndexTupleData * IndexTuple
void _bt_mark_array_keys(IndexScanDesc scan)
#define InvalidTransactionId
#define RelationGetRelationName(relation)
bool _bt_parallel_seize(IndexScanDesc scan, BlockNumber *pageno)
MemoryContext CurrentMemoryContext
#define BTREE_NOVAC_VERSION
BlockNumber pages_deleted
#define OffsetToPointer(base, offset)
#define BufferGetPage(buffer)
amrescan_function amrescan
#define P_ISDELETED(opaque)
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
TransactionId oldestBtpoXact
#define PageGetItemId(page, offsetNumber)
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
#define SpinLockRelease(lock)
bool btgettuple(IndexScanDesc scan, ScanDirection dir)
void btmarkpos(IndexScanDesc scan)
struct ParallelIndexScanDescData * parallel_scan
void * palloc0(Size size)
void _bt_lockbuf(Relation rel, Buffer buf, int access)
#define PROGRESS_SCAN_BLOCKS_DONE
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
uint16 deletetids[FLEXIBLE_ARRAY_MEMBER]
bool _bt_doinsert(Relation rel, IndexTuple itup, IndexUniqueCheck checkUnique, bool indexUnchanged, Relation heapRel)
#define RelationGetNumberOfBlocks(reln)
BlockNumber btps_scanPage
void _bt_relbuf(Relation rel, Buffer buf)
#define ereport(elevel,...)
bool GlobalVisCheckRemovableXid(Relation rel, TransactionId xid)
bool amusemaintenanceworkmem
static bool BTreeTupleIsPosting(IndexTuple itup)
int errmsg_internal(const char *fmt,...)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
amadjustmembers_function amadjustmembers
#define Assert(condition)
#define VACUUM_OPTION_PARALLEL_COND_CLEANUP
BTPS_State btps_pageStatus
void IndexFreeSpaceMapVacuum(Relation rel)
bool btproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
void btrestrpos(IndexScanDesc scan)
Datum bthandler(PG_FUNCTION_ARGS)
#define BTScanPosInvalidate(scanpos)
#define OffsetNumberNext(offsetNumber)
#define PageGetSpecialPointer(page)
#define InvalidBlockNumber
float8 btm_last_cleanup_num_heap_tuples
void PageSetChecksumInplace(Page page, BlockNumber blkno)
bool btinsert(Relation rel, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)
ammarkpos_function ammarkpos
#define PROGRESS_SCAN_BLOCKS_TOTAL
IndexBulkDeleteResult * stats
ambuildphasename_function ambuildphasename
#define VACUUM_OPTION_PARALLEL_BULKDEL
bool btcanreturn(Relation index, int attno)
void btparallelrescan(IndexScanDesc scan)
#define PG_END_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
amestimateparallelscan_function amestimateparallelscan
void _bt_parallel_release(IndexScanDesc scan, BlockNumber scan_page)
BTScanPosItem items[MaxTIDsPerBTreePage]
struct ScanKeyData * keyData
void _bt_parallel_advance_array_keys(IndexScanDesc scan)
static Datum values[MAXATTR]
#define MaxIndexTuplesPerPage
void btinitparallelscan(void *target)
XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno, Page page, bool page_std)
ambuildempty_function ambuildempty
BTArrayKeyInfo * arrayKeys
void _bt_preprocess_array_keys(IndexScanDesc scan)
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
bool _bt_next(IndexScanDesc scan, ScanDirection dir)
bytea * btoptions(Datum reloptions, bool validate)
#define BTMaxStrategyNumber
TransactionId btm_oldest_btpo_xact
BTCycleId _bt_start_vacuum(Relation rel)
#define TransactionIdIsValid(xid)
void vacuum_delay_point(void)
static void static void status(const char *fmt,...) pg_attribute_printf(1
void _bt_upgradelockbufcleanup(Relation rel, Buffer buf)
bool _bt_allequalimage(Relation rel, bool debugmessage)
void RecordFreeIndexPage(Relation rel, BlockNumber freeBlock)
amcanreturn_function amcanreturn
#define P_RIGHTMOST(opaque)
void smgrimmedsync(SMgrRelation reln, ForkNumber forknum)
void IncrBufferRefCount(Buffer buffer)
#define offsetof(type, field)
#define PageGetItem(page, itemId)
#define BTScanPosUnpinIfPinned(scanpos)
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
aminitparallelscan_function aminitparallelscan
IndexBulkDeleteResult * btbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
amrestrpos_function amrestrpos