201 itup->
t_tid = *ht_ctid;
203 result =
_bt_doinsert(rel, itup, checkUnique, indexUnchanged, heapRel);
393 ScanKey orderbys,
int norderbys)
509 if (so->numArrayKeys)
642 bool exit_loop =
false;
650 parallel_scan->ps_offset);
655 pageStatus = btscan->btps_pageStatus;
677 *pageno = btscan->btps_scanPage;
681 if (exit_loop || !status)
724 bool status_changed =
false;
727 if (parallel_scan == NULL)
731 parallel_scan->ps_offset);
743 status_changed =
true;
767 parallel_scan->ps_offset);
775 btscan->btps_arrayKeyCount++;
938 vstate.
stats = stats;
998 if (scanblkno >= num_pages)
1001 for (; scanblkno < num_pages; scanblkno++)
1048 bool attempt_pagedel;
1059 attempt_pagedel =
false;
1082 Assert(blkno <= scanblkno);
1083 if (blkno != scanblkno)
1104 (
errcode(ERRCODE_INDEX_CORRUPTED),
1105 errmsg_internal(
"right sibling %u of scanblkno %u unexpectedly in an inconsistent state in index \"%s\"",
1150 attempt_pagedel =
true;
1202 for (offnum = minoff;
1217 deletable[ndeletable++] = offnum;
1231 if (vacposting == NULL)
1239 else if (nremaining > 0)
1249 updatable[nupdatable++] = vacposting;
1260 deletable[ndeletable++] = offnum;
1265 nhtidslive += nremaining;
1274 if (ndeletable > 0 || nupdatable > 0)
1276 Assert(nhtidsdead >= ndeletable + nupdatable);
1285 for (
int i = 0;
i < nupdatable;
i++)
1324 if (minoff > maxoff)
1325 attempt_pagedel = (blkno == scanblkno);
1331 Assert(!attempt_pagedel || nhtidslive == 0);
1334 if (attempt_pagedel)
1347 Assert(blkno == scanblkno);
1356 if (backtrack_to !=
P_NONE)
1358 blkno = backtrack_to;
1383 for (
int i = 0;
i < nitem;
i++)
1390 else if (vacposting == NULL)
1402 vacposting->
itup = posting;
void pgstat_progress_update_param(int index, int64 val)
#define InvalidBlockNumber
static Datum values[MAXATTR]
void IncrBufferRefCount(Buffer buffer)
BlockNumber BufferGetBlockNumber(Buffer buffer)
void ReleaseBuffer(Buffer buffer)
void MarkBufferDirty(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)
#define OffsetToPointer(base, offset)
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, 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
#define START_CRIT_SECTION()
#define END_CRIT_SECTION()
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_unlockbuf(Relation rel, Buffer buf)
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)
#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)
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 Datum PointerGetDatum(const void *X)
#define PROGRESS_SCAN_BLOCKS_DONE
#define PROGRESS_SCAN_BLOCKS_TOTAL
#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
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_buffer(Buffer buffer, bool page_std)