PostgreSQL Source Code  git master
amapi.h File Reference
#include "access/genam.h"
Include dependency graph for amapi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  OpFamilyMember
 
struct  IndexAmRoutine
 

Typedefs

typedef enum IndexAMProperty IndexAMProperty
 
typedef struct OpFamilyMember OpFamilyMember
 
typedef IndexBuildResult *(* ambuild_function) (Relation heapRelation, Relation indexRelation, struct IndexInfo *indexInfo)
 
typedef void(* ambuildempty_function) (Relation indexRelation)
 
typedef bool(* aminsert_function) (Relation indexRelation, Datum *values, bool *isnull, ItemPointer heap_tid, Relation heapRelation, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
 
typedef IndexBulkDeleteResult *(* ambulkdelete_function) (IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
 
typedef IndexBulkDeleteResult *(* amvacuumcleanup_function) (IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
 
typedef bool(* amcanreturn_function) (Relation indexRelation, int attno)
 
typedef void(* amcostestimate_function) (struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
 
typedef bytea *(* amoptions_function) (Datum reloptions, bool validate)
 
typedef bool(* amproperty_function) (Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
 
typedef char *(* ambuildphasename_function) (int64 phasenum)
 
typedef bool(* amvalidate_function) (Oid opclassoid)
 
typedef void(* amadjustmembers_function) (Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
 
typedef IndexScanDesc(* ambeginscan_function) (Relation indexRelation, int nkeys, int norderbys)
 
typedef void(* amrescan_function) (IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
 
typedef bool(* amgettuple_function) (IndexScanDesc scan, ScanDirection direction)
 
typedef int64(* amgetbitmap_function) (IndexScanDesc scan, TIDBitmap *tbm)
 
typedef void(* amendscan_function) (IndexScanDesc scan)
 
typedef void(* ammarkpos_function) (IndexScanDesc scan)
 
typedef void(* amrestrpos_function) (IndexScanDesc scan)
 
typedef Size(* amestimateparallelscan_function) (void)
 
typedef void(* aminitparallelscan_function) (void *target)
 
typedef void(* amparallelrescan_function) (IndexScanDesc scan)
 
typedef struct IndexAmRoutine IndexAmRoutine
 

Enumerations

enum  IndexAMProperty {
  AMPROP_UNKNOWN = 0, AMPROP_ASC, AMPROP_DESC, AMPROP_NULLS_FIRST,
  AMPROP_NULLS_LAST, AMPROP_ORDERABLE, AMPROP_DISTANCE_ORDERABLE, AMPROP_RETURNABLE,
  AMPROP_SEARCH_ARRAY, AMPROP_SEARCH_NULLS, AMPROP_CLUSTERABLE, AMPROP_INDEX_SCAN,
  AMPROP_BITMAP_SCAN, AMPROP_BACKWARD_SCAN, AMPROP_CAN_ORDER, AMPROP_CAN_UNIQUE,
  AMPROP_CAN_MULTI_COL, AMPROP_CAN_EXCLUDE, AMPROP_CAN_INCLUDE
}
 

Functions

IndexAmRoutineGetIndexAmRoutine (Oid amhandler)
 
IndexAmRoutineGetIndexAmRoutineByAmId (Oid amoid, bool noerror)
 

Typedef Documentation

◆ amadjustmembers_function

typedef void(* amadjustmembers_function) (Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)

Definition at line 155 of file amapi.h.

◆ ambeginscan_function

typedef IndexScanDesc(* ambeginscan_function) (Relation indexRelation, int nkeys, int norderbys)

Definition at line 161 of file amapi.h.

◆ ambuild_function

typedef IndexBuildResult*(* ambuild_function) (Relation heapRelation, Relation indexRelation, struct IndexInfo *indexInfo)

Definition at line 99 of file amapi.h.

◆ ambuildempty_function

typedef void(* ambuildempty_function) (Relation indexRelation)

Definition at line 104 of file amapi.h.

◆ ambuildphasename_function

typedef char*(* ambuildphasename_function) (int64 phasenum)

Definition at line 149 of file amapi.h.

◆ ambulkdelete_function

typedef IndexBulkDeleteResult*(* ambulkdelete_function) (IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)

Definition at line 117 of file amapi.h.

◆ amcanreturn_function

typedef bool(* amcanreturn_function) (Relation indexRelation, int attno)

Definition at line 127 of file amapi.h.

◆ amcostestimate_function

typedef void(* amcostestimate_function) (struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)

Definition at line 130 of file amapi.h.

◆ amendscan_function

typedef void(* amendscan_function) (IndexScanDesc scan)

Definition at line 181 of file amapi.h.

◆ amestimateparallelscan_function

typedef Size(* amestimateparallelscan_function) (void)

Definition at line 194 of file amapi.h.

◆ amgetbitmap_function

typedef int64(* amgetbitmap_function) (IndexScanDesc scan, TIDBitmap *tbm)

Definition at line 177 of file amapi.h.

◆ amgettuple_function

typedef bool(* amgettuple_function) (IndexScanDesc scan, ScanDirection direction)

Definition at line 173 of file amapi.h.

◆ aminitparallelscan_function

typedef void(* aminitparallelscan_function) (void *target)

Definition at line 197 of file amapi.h.

◆ aminsert_function

typedef bool(* aminsert_function) (Relation indexRelation, Datum *values, bool *isnull, ItemPointer heap_tid, Relation heapRelation, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)

Definition at line 107 of file amapi.h.

◆ ammarkpos_function

typedef void(* ammarkpos_function) (IndexScanDesc scan)

Definition at line 184 of file amapi.h.

◆ amoptions_function

typedef bytea*(* amoptions_function) (Datum reloptions, bool validate)

Definition at line 140 of file amapi.h.

◆ amparallelrescan_function

typedef void(* amparallelrescan_function) (IndexScanDesc scan)

Definition at line 200 of file amapi.h.

◆ amproperty_function

typedef bool(* amproperty_function) (Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)

Definition at line 144 of file amapi.h.

◆ amrescan_function

typedef void(* amrescan_function) (IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)

Definition at line 166 of file amapi.h.

◆ amrestrpos_function

typedef void(* amrestrpos_function) (IndexScanDesc scan)

Definition at line 187 of file amapi.h.

◆ amvacuumcleanup_function

typedef IndexBulkDeleteResult*(* amvacuumcleanup_function) (IndexVacuumInfo *info, IndexBulkDeleteResult *stats)

Definition at line 123 of file amapi.h.

◆ amvalidate_function

typedef bool(* amvalidate_function) (Oid opclassoid)

Definition at line 152 of file amapi.h.

◆ IndexAMProperty

◆ IndexAmRoutine

◆ OpFamilyMember

Enumeration Type Documentation

◆ IndexAMProperty

Enumerator
AMPROP_UNKNOWN 
AMPROP_ASC 
AMPROP_DESC 
AMPROP_NULLS_FIRST 
AMPROP_NULLS_LAST 
AMPROP_ORDERABLE 
AMPROP_DISTANCE_ORDERABLE 
AMPROP_RETURNABLE 
AMPROP_SEARCH_ARRAY 
AMPROP_SEARCH_NULLS 
AMPROP_CLUSTERABLE 
AMPROP_INDEX_SCAN 
AMPROP_BITMAP_SCAN 
AMPROP_BACKWARD_SCAN 
AMPROP_CAN_ORDER 
AMPROP_CAN_UNIQUE 
AMPROP_CAN_MULTI_COL 
AMPROP_CAN_EXCLUDE 
AMPROP_CAN_INCLUDE 

Definition at line 34 of file amapi.h.

Function Documentation

◆ GetIndexAmRoutine()

IndexAmRoutine* GetIndexAmRoutine ( Oid  amhandler)

Definition at line 33 of file amapi.c.

References DatumGetPointer, elog, ERROR, IsA, and OidFunctionCall0.

Referenced by CheckIndexCompatible(), DefineIndex(), GetIndexAmRoutineByAmId(), InitIndexAmRoutine(), and pg_get_indexdef_worker().

34 {
35  Datum datum;
36  IndexAmRoutine *routine;
37 
38  datum = OidFunctionCall0(amhandler);
39  routine = (IndexAmRoutine *) DatumGetPointer(datum);
40 
41  if (routine == NULL || !IsA(routine, IndexAmRoutine))
42  elog(ERROR, "index access method handler function %u did not return an IndexAmRoutine struct",
43  amhandler);
44 
45  return routine;
46 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:584
#define ERROR
Definition: elog.h:45
uintptr_t Datum
Definition: postgres.h:367
#define OidFunctionCall0(functionId)
Definition: fmgr.h:662
#define DatumGetPointer(X)
Definition: postgres.h:549
#define elog(elevel,...)
Definition: elog.h:227

◆ GetIndexAmRoutineByAmId()

IndexAmRoutine* GetIndexAmRoutineByAmId ( Oid  amoid,
bool  noerror 
)

Definition at line 56 of file amapi.c.

References AMOID, elog, ereport, errcode(), errmsg(), ERROR, GetIndexAmRoutine(), GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, RegProcedureIsValid, ReleaseSysCache(), and SearchSysCache1().

Referenced by AlterOpFamily(), AlterOpFamilyAdd(), amvalidate(), assignOperTypes(), ConstructTupleDescriptor(), DefineOpClass(), indexam_property(), IndexSupportsBackwardScan(), and pg_indexam_progress_phasename().

57 {
58  HeapTuple tuple;
59  Form_pg_am amform;
60  regproc amhandler;
61 
62  /* Get handler function OID for the access method */
63  tuple = SearchSysCache1(AMOID, ObjectIdGetDatum(amoid));
64  if (!HeapTupleIsValid(tuple))
65  {
66  if (noerror)
67  return NULL;
68  elog(ERROR, "cache lookup failed for access method %u",
69  amoid);
70  }
71  amform = (Form_pg_am) GETSTRUCT(tuple);
72 
73  /* Check if it's an index access method as opposed to some other AM */
74  if (amform->amtype != AMTYPE_INDEX)
75  {
76  if (noerror)
77  {
78  ReleaseSysCache(tuple);
79  return NULL;
80  }
81  ereport(ERROR,
82  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
83  errmsg("access method \"%s\" is not of type %s",
84  NameStr(amform->amname), "INDEX")));
85  }
86 
87  amhandler = amform->amhandler;
88 
89  /* Complain if handler OID is invalid */
90  if (!RegProcedureIsValid(amhandler))
91  {
92  if (noerror)
93  {
94  ReleaseSysCache(tuple);
95  return NULL;
96  }
97  ereport(ERROR,
98  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
99  errmsg("index access method \"%s\" does not have a handler",
100  NameStr(amform->amname))));
101  }
102 
103  ReleaseSysCache(tuple);
104 
105  /* And finally, call the handler function to get the API struct. */
106  return GetIndexAmRoutine(amhandler);
107 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Definition: syscache.h:36
int errcode(int sqlerrcode)
Definition: elog.c:694
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:45
IndexAmRoutine * GetIndexAmRoutine(Oid amhandler)
Definition: amapi.c:33
#define RegProcedureIsValid(p)
Definition: c.h:712
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define ereport(elevel,...)
Definition: elog.h:155
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Oid regproc
Definition: c.h:584
FormData_pg_am * Form_pg_am
Definition: pg_am.h:48
int errmsg(const char *fmt,...)
Definition: elog.c:905
#define elog(elevel,...)
Definition: elog.h:227
#define NameStr(name)
Definition: c.h:681