75 #define RELATION_CHECKS \
77 Assert(RelationIsValid(indexRelation)); \
78 Assert(PointerIsValid(indexRelation->rd_indam)); \
79 if (unlikely(ReindexIsProcessingIndex(RelationGetRelid(indexRelation)))) \
81 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
82 errmsg("cannot access index \"%s\" while it is being reindexed", \
83 RelationGetRelationName(indexRelation)))); \
88 AssertMacro(IndexScanIsValid(scan)), \
89 AssertMacro(RelationIsValid(scan->indexRelation)), \
90 AssertMacro(PointerIsValid(scan->indexRelation->rd_indam)) \
93 #define CHECK_REL_PROCEDURE(pname) \
95 if (indexRelation->rd_indam->pname == NULL) \
96 elog(ERROR, "function \"%s\" is not defined for index \"%s\"", \
97 CppAsString(pname), RelationGetRelationName(indexRelation)); \
100 #define CHECK_SCAN_PROCEDURE(pname) \
102 if (scan->indexRelation->rd_indam->pname == NULL) \
103 elog(ERROR, "function \"%s\" is not defined for index \"%s\"", \
104 CppAsString(pname), RelationGetRelationName(scan->indexRelation)); \
108 int nkeys,
int norderbys,
Snapshot snapshot,
199 if (r->
rd_rel->relkind != RELKIND_INDEX &&
200 r->
rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
202 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
203 errmsg(
"\"%s\" is not an index",
231 heap_t_ctid, heapRelation,
232 checkUnique, indexUnchanged,
259 int nkeys,
int norderbys)
311 int nkeys,
int norderbys,
Snapshot snapshot,
354 ScanKey orderbys,
int norderbys)
370 orderbys, norderbys);
634 bool all_dead =
false;
751 void *callback_state)
838 procindex = (nproc * (
attnum - 1)) + (procnum - 1);
844 return loc[procindex];
874 procindex = (nproc * (
attnum - 1)) + (procnum - 1);
880 locinfo += procindex;
890 procId = loc[procindex];
899 elog(
ERROR,
"missing support function %d for attribute %d of index \"%s\"",
904 if (procnum != optsproc)
934 Assert(distances || !recheckOrderBy);
940 if (orderByTypes[
i] == FLOAT8OID)
942 #ifndef USE_FLOAT8_BYVAL
947 if (distances && !distances[
i].isnull)
958 else if (orderByTypes[
i] == FLOAT4OID)
961 if (distances && !distances[
i].isnull)
983 elog(
ERROR,
"ORDER BY operator must return float8 or float4 if the distance function is lossy");
1005 if (amoptsprocnum != 0)
1011 Datum indclassDatum;
1022 Anum_pg_index_indclass);
1027 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1028 errmsg(
"operator class %s has no options",
#define InvalidBlockNumber
static Datum values[MAXATTR]
#define OffsetToPointer(base, offset)
#define RegProcedureIsValid(p)
#define Assert(condition)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void set_fn_opclass_options(FmgrInfo *flinfo, bytea *options)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
Datum Float8GetDatum(float8 X)
#define FunctionCall1(flinfo, arg1)
void IndexScanEnd(IndexScanDesc scan)
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
IndexBulkDeleteResult * index_vacuum_cleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *istat)
#define CHECK_REL_PROCEDURE(pname)
static void validate_relation_kind(Relation r)
bool index_insert(Relation indexRelation, Datum *values, bool *isnull, ItemPointer heap_t_ctid, Relation heapRelation, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)
void index_restrpos(IndexScanDesc scan)
static IndexScanDesc index_beginscan_internal(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot, ParallelIndexScanDesc pscan, bool temp_snap)
IndexScanDesc index_beginscan_parallel(Relation heaprel, Relation indexrel, int nkeys, int norderbys, ParallelIndexScanDesc pscan)
IndexScanDesc index_beginscan_bitmap(Relation indexRelation, Snapshot snapshot, int nkeys)
void index_insert_cleanup(Relation indexRelation, IndexInfo *indexInfo)
void index_close(Relation relation, LOCKMODE lockmode)
bool index_can_return(Relation indexRelation, int attno)
ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, int norderbys)
RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum)
bool index_fetch_heap(IndexScanDesc scan, TupleTableSlot *slot)
void index_markpos(IndexScanDesc scan)
Relation try_index_open(Oid relationId, LOCKMODE lockmode)
void index_endscan(IndexScanDesc scan)
Size index_parallelscan_estimate(Relation indexRelation, int nkeys, int norderbys, Snapshot snapshot)
IndexBulkDeleteResult * index_bulk_delete(IndexVacuumInfo *info, IndexBulkDeleteResult *istat, IndexBulkDeleteCallback callback, void *callback_state)
void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, ParallelIndexScanDesc target)
Relation index_open(Oid relationId, LOCKMODE lockmode)
bytea * index_opclass_options(Relation indrel, AttrNumber attnum, Datum attoptions, bool validate)
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)
#define CHECK_SCAN_PROCEDURE(pname)
void index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes, IndexOrderByDistance *distances, bool recheckOrderBy)
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
static bool ItemPointerIsValid(const ItemPointerData *pointer)
void UnlockRelationId(LockRelId *relid, LOCKMODE lockmode)
void pfree(void *pointer)
#define pgstat_count_index_tuples(rel, n)
#define pgstat_count_heap_fetch(rel)
static Datum PointerGetDatum(const void *X)
static Datum Float4GetDatum(float4 X)
static Pointer DatumGetPointer(Datum X)
void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
void PredicateLockRelation(Relation relation, Snapshot snapshot)
MemoryContextSwitchTo(old_ctx)
#define RelationGetRelid(relation)
#define RelationGetRelationName(relation)
void RelationDecrementReferenceCount(Relation rel)
void RelationIncrementReferenceCount(Relation rel)
bytea ** RelationGetIndexAttOptions(Relation relation, bool copy)
void RelationClose(Relation relation)
void init_local_reloptions(local_relopts *relopts, Size relopt_struct_size)
void * build_local_reloptions(local_relopts *relopts, Datum options, bool validate)
char * generate_opclass_name(Oid opclass)
Size add_size(Size s1, Size s2)
void SerializeSnapshot(Snapshot snapshot, char *start_address)
void UnregisterSnapshot(Snapshot snapshot)
Snapshot RestoreSnapshot(char *start_address)
Snapshot RegisterSnapshot(Snapshot snapshot)
Size EstimateSnapshotSpace(Snapshot snapshot)
#define IsMVCCSnapshot(snapshot)
Relation try_relation_open(Oid relationId, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
amvacuumcleanup_function amvacuumcleanup
amestimateparallelscan_function amestimateparallelscan
amrestrpos_function amrestrpos
aminsert_function aminsert
amendscan_function amendscan
amparallelrescan_function amparallelrescan
amgettuple_function amgettuple
amcanreturn_function amcanreturn
amgetbitmap_function amgetbitmap
ambulkdelete_function ambulkdelete
ammarkpos_function ammarkpos
ambeginscan_function ambeginscan
amrescan_function amrescan
aminitparallelscan_function aminitparallelscan
aminsertcleanup_function aminsertcleanup
struct ParallelIndexScanDescData * parallel_scan
IndexFetchTableData * xs_heapfetch
bool xactStartedInRecovery
ItemPointerData xs_heaptid
struct SnapshotData * xs_snapshot
char ps_snapshot_data[FLEXIBLE_ARRAY_MEMBER]
struct IndexAmRoutine * rd_indam
RegProcedure * rd_support
struct HeapTupleData * rd_indextuple
MemoryContext rd_indexcxt
struct FmgrInfo * rd_supportinfo
Oid values[FLEXIBLE_ARRAY_MEMBER]
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
static IndexFetchTableData * table_index_fetch_begin(Relation rel)
static void table_index_fetch_reset(struct IndexFetchTableData *scan)
static void table_index_fetch_end(struct IndexFetchTableData *scan)
static bool table_index_fetch_tuple(struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, bool *call_again, bool *all_dead)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
#define TransactionIdIsValid(xid)