35 #include "utils/fmgrprotos.h"
194 itup->
t_tid = *ht_ctid;
196 result =
_bt_doinsert(rel, itup, checkUnique, indexUnchanged, heapRel);
361 ScanKey orderbys,
int norderbys)
606 bool exit_loop =
false;
633 parallel_scan->ps_offset);
657 array->
cur_elem = btscan->btps_arrElems[
i];
687 *pageno = btscan->btps_scanPage;
691 if (exit_loop || !status)
740 bool status_changed =
false;
743 if (parallel_scan == NULL)
754 parallel_scan->ps_offset);
765 status_changed =
true;
792 parallel_scan->ps_offset);
795 if (btscan->btps_scanPage == prev_scan_page &&
806 btscan->btps_arrElems[
i] = array->
cur_elem;
970 vstate.
stats = stats;
1030 if (scanblkno >= num_pages)
1033 for (; scanblkno < num_pages; scanblkno++)
1080 bool attempt_pagedel;
1091 attempt_pagedel =
false;
1114 Assert(blkno <= scanblkno);
1115 if (blkno != scanblkno)
1136 (
errcode(ERRCODE_INDEX_CORRUPTED),
1137 errmsg_internal(
"right sibling %u of scanblkno %u unexpectedly in an inconsistent state in index \"%s\"",
1182 attempt_pagedel =
true;
1234 for (offnum = minoff;
1249 deletable[ndeletable++] = offnum;
1263 if (vacposting == NULL)
1271 else if (nremaining > 0)
1281 updatable[nupdatable++] = vacposting;
1292 deletable[ndeletable++] = offnum;
1297 nhtidslive += nremaining;
1306 if (ndeletable > 0 || nupdatable > 0)
1308 Assert(nhtidsdead >= ndeletable + nupdatable);
1317 for (
int i = 0;
i < nupdatable;
i++)
1356 if (minoff > maxoff)
1357 attempt_pagedel = (blkno == scanblkno);
1363 Assert(!attempt_pagedel || nhtidslive == 0);
1366 if (attempt_pagedel)
1379 Assert(blkno == scanblkno);
1388 if (backtrack_to !=
P_NONE)
1390 blkno = backtrack_to;
1415 for (
int i = 0;
i < nitem;
i++)
1422 else if (vacposting == NULL)
1434 vacposting->
itup = posting;
void pgstat_progress_update_param(int index, int64 val)
#define InvalidBlockNumber
static Datum values[MAXATTR]
void IncrBufferRefCount(Buffer buffer)
void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
void smgr_bulk_write(BulkWriteState *bulkstate, BlockNumber blocknum, BulkWriteBuffer buf, bool page_std)
BulkWriteBuffer smgr_bulk_get_buf(BulkWriteState *bulkstate)
void smgr_bulk_finish(BulkWriteState *bulkstate)
BulkWriteState * smgr_bulk_start_rel(Relation rel, ForkNumber forknum)
#define OffsetToPointer(base, offset)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void ConditionVariableSignal(ConditionVariable *cv)
static void PGresult * res
int errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
#define ereport(elevel,...)
#define PG_RETURN_POINTER(x)
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
void IndexFreeSpaceMapVacuum(Relation rel)
void RecordFreeIndexPage(Relation rel, BlockNumber freeBlock)
IndexTuple index_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
#define PG_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
#define PG_END_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
if(TABLE==NULL||TABLE_index==NULL)
IndexTupleData * IndexTuple
#define MaxIndexTuplesPerPage
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
bool _bt_doinsert(Relation rel, IndexTuple itup, IndexUniqueCheck checkUnique, bool indexUnchanged, Relation heapRel)
void _bt_relbuf(Relation rel, Buffer buf)
int _bt_getrootheight(Relation rel)
void _bt_pagedel(Relation rel, Buffer leafbuf, BTVacState *vstate)
void _bt_delitems_vacuum(Relation rel, Buffer buf, OffsetNumber *deletable, int ndeletable, BTVacuumPosting *updatable, int nupdatable)
void _bt_checkpage(Relation rel, Buffer buf)
void _bt_set_cleanup_info(Relation rel, BlockNumber num_delpages)
void _bt_upgradelockbufcleanup(Relation rel, Buffer buf)
void _bt_initmetapage(Page page, BlockNumber rootbknum, uint32 level, bool allequalimage)
bool _bt_vacuum_needs_cleanup(Relation rel)
void _bt_pendingfsm_finalize(Relation rel, BTVacState *vstate)
void _bt_lockbuf(Relation rel, Buffer buf, int access)
void _bt_pendingfsm_init(Relation rel, BTVacState *vstate, bool cleanuponly)
bool btcanreturn(Relation index, int attno)
void _bt_parallel_release(IndexScanDesc scan, BlockNumber scan_page)
@ BTPARALLEL_NEED_PRIMSCAN
@ BTPARALLEL_NOT_INITIALIZED
IndexScanDesc btbeginscan(Relation rel, int nkeys, int norderbys)
void _bt_parallel_done(IndexScanDesc scan)
IndexBulkDeleteResult * btbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
static BTVacuumPosting btreevacuumposting(BTVacState *vstate, IndexTuple posting, OffsetNumber updatedoffset, int *nremaining)
IndexBulkDeleteResult * btvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
bool btgettuple(IndexScanDesc scan, ScanDirection dir)
void btparallelrescan(IndexScanDesc scan)
struct BTParallelScanDescData BTParallelScanDescData
bool btinsert(Relation rel, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)
void btbuildempty(Relation index)
static void btvacuumpage(BTVacState *vstate, BlockNumber scanblkno)
int btgettreeheight(Relation rel)
void btinitparallelscan(void *target)
static void btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state, BTCycleId cycleid)
bool _bt_parallel_seize(IndexScanDesc scan, BlockNumber *pageno, bool first)
Size btestimateparallelscan(int nkeys, int norderbys)
int64 btgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
void btmarkpos(IndexScanDesc scan)
void btendscan(IndexScanDesc scan)
void btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
struct BTParallelScanDescData * BTParallelScanDesc
Datum bthandler(PG_FUNCTION_ARGS)
void _bt_parallel_primscan_schedule(IndexScanDesc scan, BlockNumber prev_scan_page)
void btrestrpos(IndexScanDesc scan)
#define P_ISHALFDEAD(opaque)
#define BTScanPosIsPinned(scanpos)
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
static bool BTreeTupleIsPivot(IndexTuple itup)
#define BTPageGetOpaque(page)
#define P_ISDELETED(opaque)
static ItemPointer BTreeTupleGetPosting(IndexTuple posting)
#define MaxTIDsPerBTreePage
#define BTScanPosIsValid(scanpos)
#define P_FIRSTDATAKEY(opaque)
#define P_RIGHTMOST(opaque)
static bool BTPageIsRecyclable(Page page, Relation heaprel)
static bool BTreeTupleIsPosting(IndexTuple itup)
#define BTScanPosInvalidate(scanpos)
#define BTScanPosUnpinIfPinned(scanpos)
BTScanOpaqueData * BTScanOpaque
bool _bt_first(IndexScanDesc scan, ScanDirection dir)
bool _bt_next(IndexScanDesc scan, ScanDirection dir)
IndexBuildResult * btbuild(Relation heap, Relation index, IndexInfo *indexInfo)
void _bt_end_vacuum(Relation rel)
char * btbuildphasename(int64 phasenum)
void _bt_end_vacuum_callback(int code, Datum arg)
bytea * btoptions(Datum reloptions, bool validate)
void _bt_killitems(IndexScanDesc scan)
bool _bt_start_prim_scan(IndexScanDesc scan, ScanDirection dir)
bool btproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
bool _bt_allequalimage(Relation rel, bool debugmessage)
void _bt_start_array_keys(IndexScanDesc scan, ScanDirection dir)
BTCycleId _bt_start_vacuum(Relation rel)
bool btvalidate(Oid opclassoid)
void btadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
#define OffsetNumberNext(offsetNumber)
static Datum PointerGetDatum(const void *X)
#define PROGRESS_SCAN_BLOCKS_DONE
#define PROGRESS_SCAN_BLOCKS_TOTAL
MemoryContextSwitchTo(old_ctx)
#define RELATION_IS_LOCAL(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
void btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
#define BTMaxStrategyNumber
BTPS_State btps_pageStatus
ConditionVariable btps_cv
BlockNumber btps_scanPage
int btps_arrElems[FLEXIBLE_ARRAY_MEMBER]
BTArrayKeyInfo * arrayKeys
MemoryContext arrayContext
BTScanPosItem items[MaxTIDsPerBTreePage]
IndexBulkDeleteResult * stats
BTPendingFSM * pendingpages
IndexBulkDeleteCallback callback
MemoryContext pagedelcontext
uint16 deletetids[FLEXIBLE_ARRAY_MEMBER]
OffsetNumber updatedoffset
ambuildphasename_function ambuildphasename
ambuildempty_function ambuildempty
amvacuumcleanup_function amvacuumcleanup
amoptions_function amoptions
amestimateparallelscan_function amestimateparallelscan
amrestrpos_function amrestrpos
aminsert_function aminsert
amendscan_function amendscan
amparallelrescan_function amparallelrescan
amcostestimate_function amcostestimate
amadjustmembers_function amadjustmembers
amgettuple_function amgettuple
amcanreturn_function amcanreturn
amgetbitmap_function amgetbitmap
amproperty_function amproperty
ambulkdelete_function ambulkdelete
amvalidate_function amvalidate
ammarkpos_function ammarkpos
bool amusemaintenanceworkmem
ambeginscan_function ambeginscan
amrescan_function amrescan
aminitparallelscan_function aminitparallelscan
uint8 amparallelvacuumoptions
aminsertcleanup_function aminsertcleanup
amgettreeheight_function amgettreeheight
BlockNumber pages_deleted
struct ScanKeyData * keyData
struct ParallelIndexScanDescData * parallel_scan
struct TupleDescData * xs_itupdesc
ItemPointerData xs_heaptid
BufferAccessStrategy strategy
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
void tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids, bool recheck)
void vacuum_delay_point(void)
#define VACUUM_OPTION_PARALLEL_BULKDEL
#define VACUUM_OPTION_PARALLEL_COND_CLEANUP