1/*-------------------------------------------------------------------------
4 * POSTGRES generalized index access method definitions.
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/access/genam.h
12 *-------------------------------------------------------------------------
25/* We don't want this file to depend on execnodes.h. */
34 * Struct for statistics maintained by amgettuple and amgetbitmap
36 * Note: IndexScanInstrumentation can't contain any pointers, since it is
37 * copied into a SharedIndexScanInstrumentation during parallel scans
41 /* Index search count (incremented with pgstat_count_index_scan call) */
46 * Struct for every worker's IndexScanInstrumentation, stored in shared memory
55 * Struct for statistics returned by ambuild
64 * Struct for input arguments passed to ambulkdelete and amvacuumcleanup
66 * num_heap_tuples is accurate only when estimated_count is false;
67 * otherwise it's just an estimate (currently, the estimate is the
68 * prior value of the relation's pg_class.reltuples field, so it could
69 * even be -1). It will always just be an estimate during ambulkdelete.
84 * Struct for statistics returned by ambulkdelete and amvacuumcleanup
86 * This struct is normally allocated by the first ambulkdelete call and then
87 * passed along through subsequent ones until amvacuumcleanup; however,
88 * amvacuumcleanup must be prepared to allocate it in the case where no
89 * ambulkdelete calls were made (because no tuples needed deletion).
90 * Note that an index AM could choose to return a larger struct
91 * of which this is just the first field; this provides a way for ambulkdelete
92 * to communicate additional private data to amvacuumcleanup.
94 * Note: pages_newly_deleted is the number of pages in the index that were
95 * deleted by the current vacuum operation. pages_deleted and pages_free
96 * refer to free space within the index file.
98 * Note: Some index AMs may compute num_index_tuples by reference to
99 * num_heap_tuples, in which case they should copy the estimated_count field
100 * from IndexVacuumInfo.
113/* Typedef for callback function to determine if a tuple is bulk-deletable */
116/* struct definitions appear in relscan.h */
123 * Enumeration specifying the type of uniqueness check to perform in
126 * UNIQUE_CHECK_YES is the traditional Postgres immediate check, possibly
127 * blocking to see if a conflicting transaction commits.
129 * For deferrable unique constraints, UNIQUE_CHECK_PARTIAL is specified at
130 * insertion time. The index AM should test if the tuple is unique, but
131 * should not throw error, block, or prevent the insertion if the tuple
132 * appears not to be unique. We'll recheck later when it is time for the
133 * constraint to be enforced. The AM must return true if the tuple is
134 * known unique, false if it is possibly non-unique. In the "true" case
135 * it is safe to omit the later recheck.
137 * When it is time to recheck the deferred constraint, a pseudo-insertion
138 * call is made with UNIQUE_CHECK_EXISTING. The tuple is already in the
139 * index in this case, so it should not be inserted again. Rather, just
140 * check for conflicting live tuples (possibly blocking).
151/* Nullable "ORDER BY col op const" distance */
159 * generalized index_ interface routines (in indexam.c)
180 int nkeys,
int norderbys);
187 ScanKey orderbys,
int norderbys);
192 int nkeys,
int norderbys,
Snapshot snapshot,
193 bool instrument,
bool parallel_aware,
197 bool instrument,
bool parallel_aware,
205 int nkeys,
int norderbys,
217 void *callback_state);
228 bool recheckOrderBy);
234 * index access method support routines (in genam.c)
237 int nkeys,
int norderbys);
248 * heap-or-index access to system catalogs (in genam.c)
static bool validate(Port *port, const char *auth)
static Datum values[MAXATTR]
#define FLEXIBLE_ARRAY_MEMBER
char * BuildIndexValueDescription(Relation indexRelation, const Datum *values, const bool *isnull)
void systable_endscan(SysScanDesc sysscan)
void systable_inplace_update_cancel(void *state)
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, bool instrument, bool parallel_aware, int nworkers, SharedIndexScanInstrumentation **sharedinfo, ParallelIndexScanDesc target)
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
struct RelationData * Relation
struct IndexOrderByDistance IndexOrderByDistance
bool systable_recheck_tuple(SysScanDesc sysscan, HeapTuple tup)
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
void IndexScanEnd(IndexScanDesc scan)
bool index_insert(Relation indexRelation, Datum *values, bool *isnull, ItemPointer heap_t_ctid, Relation heapRelation, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, IndexScanInstrumentation *instrument, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
void index_restrpos(IndexScanDesc scan)
IndexBulkDeleteResult * index_vacuum_cleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *istat)
bytea * index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions, bool validate)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys, int norderbys)
IndexBulkDeleteResult * index_bulk_delete(IndexVacuumInfo *info, IndexBulkDeleteResult *istat, IndexBulkDeleteCallback callback, void *callback_state)
struct IndexVacuumInfo IndexVacuumInfo
void index_insert_cleanup(Relation indexRelation, IndexInfo *indexInfo)
void systable_inplace_update_begin(Relation relation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, const ScanKeyData *key, HeapTuple *oldtupcopy, void **state)
TransactionId index_compute_xid_horizon_for_tuples(Relation irel, Relation hrel, Buffer ibuf, OffsetNumber *itemnos, int nitems)
void index_close(Relation relation, LOCKMODE lockmode)
bool index_can_return(Relation indexRelation, int attno)
struct IndexScanInstrumentation IndexScanInstrumentation
struct IndexBuildResult IndexBuildResult
ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
SysScanDesc systable_beginscan_ordered(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, ScanKey key)
void systable_inplace_update_finish(void *state, HeapTuple tuple)
HeapTuple systable_getnext(SysScanDesc sysscan)
RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum)
bool index_fetch_heap(IndexScanDesc scan, TupleTableSlot *slot)
void systable_endscan_ordered(SysScanDesc sysscan)
HeapTuple systable_getnext_ordered(SysScanDesc sysscan, ScanDirection direction)
void index_markpos(IndexScanDesc scan)
Relation try_index_open(Oid relationId, LOCKMODE lockmode)
void index_endscan(IndexScanDesc scan)
struct IndexBulkDeleteResult IndexBulkDeleteResult
IndexScanDesc index_beginscan_bitmap(Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys)
Size index_parallelscan_estimate(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot, bool instrument, bool parallel_aware, int nworkers)
Relation index_open(Oid relationId, LOCKMODE lockmode)
struct SysScanDescData * SysScanDesc
int64 index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
void index_parallelrescan(IndexScanDesc scan)
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
struct ParallelIndexScanDescData * ParallelIndexScanDesc
struct IndexScanDescData * IndexScanDesc
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
struct SharedIndexScanInstrumentation SharedIndexScanInstrumentation
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
void index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes, IndexOrderByDistance *distances, bool recheckOrderBy)
BlockNumber pages_deleted
BlockNumber pages_newly_deleted
BufferAccessStrategy strategy
IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER]
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)