PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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  IndexAmRoutine
 

Typedefs

typedef enum IndexAMProperty IndexAMProperty
 
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, 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 bool(* amvalidate_function )(Oid opclassoid)
 
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
}
 

Functions

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

Typedef Documentation

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

Definition at line 114 of file amapi.h.

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

Definition at line 62 of file amapi.h.

typedef void(* ambuildempty_function)(Relation indexRelation)

Definition at line 67 of file amapi.h.

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

Definition at line 79 of file amapi.h.

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

Definition at line 89 of file amapi.h.

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 92 of file amapi.h.

typedef void(* amendscan_function)(IndexScanDesc scan)

Definition at line 134 of file amapi.h.

typedef Size(* amestimateparallelscan_function)(void)

Definition at line 147 of file amapi.h.

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

Definition at line 130 of file amapi.h.

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

Definition at line 126 of file amapi.h.

typedef void(* aminitparallelscan_function)(void *target)

Definition at line 150 of file amapi.h.

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

Definition at line 70 of file amapi.h.

typedef void(* ammarkpos_function)(IndexScanDesc scan)

Definition at line 137 of file amapi.h.

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

Definition at line 102 of file amapi.h.

typedef void(* amparallelrescan_function)(IndexScanDesc scan)

Definition at line 153 of file amapi.h.

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

Definition at line 106 of file amapi.h.

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

Definition at line 119 of file amapi.h.

typedef void(* amrestrpos_function)(IndexScanDesc scan)

Definition at line 140 of file amapi.h.

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

Definition at line 85 of file amapi.h.

typedef bool(* amvalidate_function)(Oid opclassoid)

Definition at line 111 of file amapi.h.

Enumeration Type Documentation

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 

Definition at line 34 of file amapi.h.

Function Documentation

IndexAmRoutine* GetIndexAmRoutine ( Oid  amhandler)

Definition at line 33 of file amapi.c.

References DatumGetPointer, elog, ERROR, IsA, NULL, 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:560
#define ERROR
Definition: elog.h:43
uintptr_t Datum
Definition: postgres.h:372
#define OidFunctionCall0(functionId)
Definition: fmgr.h:620
#define NULL
Definition: c.h:229
#define DatumGetPointer(X)
Definition: postgres.h:555
#define elog
Definition: elog.h:219
IndexAmRoutine* GetIndexAmRoutineByAmId ( Oid  amoid,
bool  noerror 
)

Definition at line 56 of file amapi.c.

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

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

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:656
Definition: syscache.h:36
int errcode(int sqlerrcode)
Definition: elog.c:575
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:156
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
IndexAmRoutine * GetIndexAmRoutine(Oid amhandler)
Definition: amapi.c:33
#define RegProcedureIsValid(p)
Definition: c.h:540
#define ereport(elevel, rest)
Definition: elog.h:122
#define AMTYPE_INDEX
Definition: pg_am.h:61
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1117
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
Oid regproc
Definition: c.h:394
FormData_pg_am * Form_pg_am
Definition: pg_am.h:46
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define NameStr(name)
Definition: c.h:499
#define elog
Definition: elog.h:219