199 itup->
t_tid = *ht_ctid;
201 result =
_bt_doinsert(rel, itup, checkUnique, indexUnchanged, heapRel);
391 ScanKey orderbys,
int norderbys)
507 if (so->numArrayKeys)
640 bool exit_loop =
false;
648 parallel_scan->ps_offset);
653 pageStatus = btscan->btps_pageStatus;
675 *pageno = btscan->btps_scanPage;
722 bool status_changed =
false;
725 if (parallel_scan == NULL)
729 parallel_scan->ps_offset);
741 status_changed =
true;
765 parallel_scan->ps_offset);
773 btscan->btps_arrayKeyCount++;
936 vstate.
stats = stats;
993 if (scanblkno >= num_pages)
996 for (; scanblkno < num_pages; scanblkno++)
1042 bool attempt_pagedel;
1053 attempt_pagedel =
false;
1076 Assert(blkno <= scanblkno);
1077 if (blkno != scanblkno)
1099 (
errcode(ERRCODE_INDEX_CORRUPTED),
1100 errmsg_internal(
"right sibling %u of scanblkno %u unexpectedly in an inconsistent state in index \"%s\"",
1145 attempt_pagedel =
true;
1197 for (offnum = minoff;
1212 deletable[ndeletable++] = offnum;
1226 if (vacposting == NULL)
1234 else if (nremaining > 0)
1244 updatable[nupdatable++] = vacposting;
1255 deletable[ndeletable++] = offnum;
1260 nhtidslive += nremaining;
1269 if (ndeletable > 0 || nupdatable > 0)
1271 Assert(nhtidsdead >= ndeletable + nupdatable);
1280 for (
int i = 0;
i < nupdatable;
i++)
1319 if (minoff > maxoff)
1320 attempt_pagedel = (blkno == scanblkno);
1326 Assert(!attempt_pagedel || nhtidslive == 0);
1329 if (attempt_pagedel)
1342 Assert(blkno == scanblkno);
1351 if (backtrack_to !=
P_NONE)
1353 blkno = backtrack_to;
1378 for (
int i = 0;
i < nitem;
i++)
1385 else if (vacposting == NULL)
1397 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)
void PageSetChecksumInplace(Page page, BlockNumber blkno)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define OffsetToPointer(base, offset)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void ConditionVariableSignal(ConditionVariable *cv)
void ConditionVariableCancelSleep(void)
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, Datum *values, 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
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
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_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)
void _bt_parallel_advance_array_keys(IndexScanDesc scan)
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)
bool _bt_parallel_seize(IndexScanDesc scan, BlockNumber *pageno)
static void btvacuumpage(BTVacState *vstate, BlockNumber scanblkno)
Size btestimateparallelscan(void)
void btinitparallelscan(void *target)
static void btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state, BTCycleId cycleid)
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 btrestrpos(IndexScanDesc scan)
#define P_ISHALFDEAD(opaque)
#define BTScanPosIsPinned(scanpos)
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
static bool BTreeTupleIsPivot(IndexTuple itup)
static bool BTPageIsRecyclable(Page page)
#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 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)
bool _bt_advance_array_keys(IndexScanDesc scan, ScanDirection dir)
void _bt_killitems(IndexScanDesc scan)
void _bt_preprocess_array_keys(IndexScanDesc scan)
void _bt_restore_array_keys(IndexScanDesc scan)
void _bt_mark_array_keys(IndexScanDesc scan)
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 MemoryContext MemoryContextSwitchTo(MemoryContext context)
static void static void status(const char *fmt,...) pg_attribute_printf(1
static Datum PointerGetDatum(const void *X)
#define PROGRESS_SCAN_BLOCKS_DONE
#define PROGRESS_SCAN_BLOCKS_TOTAL
#define RELATION_IS_LOCAL(relation)
static SMgrRelation RelationGetSmgr(Relation rel)
#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)
void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void *buffer, bool skipFsync)
void smgrimmedsync(SMgrRelation reln, ForkNumber forknum)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
#define BTMaxStrategyNumber
BTPS_State btps_pageStatus
ConditionVariable btps_cv
BlockNumber btps_scanPage
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
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
XLogRecPtr log_newpage(RelFileLocator *rlocator, ForkNumber forknum, BlockNumber blkno, Page page, bool page_std)