gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 line
7.4KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * amapi.h
  4. * API for Postgres index access methods.
  5. *
  6. * Copyright (c) 2015-2019, PostgreSQL Global Development Group
  7. *
  8. * src/include/access/amapi.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef AMAPI_H
  13. #define AMAPI_H
  14. #include "access/genam.h"
  15. /*
  16. * We don't wish to include planner header files here, since most of an index
  17. * AM's implementation isn't concerned with those data structures. To allow
  18. * declaring amcostestimate_function here, use forward struct references.
  19. */
  20. struct PlannerInfo;
  21. struct IndexPath;
  22. /* Likewise, this file shouldn't depend on execnodes.h. */
  23. struct IndexInfo;
  24. /*
  25. * Properties for amproperty API. This list covers properties known to the
  26. * core code, but an index AM can define its own properties, by matching the
  27. * string property name.
  28. */
  29. typedef enum IndexAMProperty
  30. {
  31. AMPROP_UNKNOWN = 0, /* anything not known to core code */
  32. AMPROP_ASC, /* column properties */
  33. AMPROP_DESC,
  34. AMPROP_NULLS_FIRST,
  35. AMPROP_NULLS_LAST,
  36. AMPROP_ORDERABLE,
  37. AMPROP_DISTANCE_ORDERABLE,
  38. AMPROP_RETURNABLE,
  39. AMPROP_SEARCH_ARRAY,
  40. AMPROP_SEARCH_NULLS,
  41. AMPROP_CLUSTERABLE, /* index properties */
  42. AMPROP_INDEX_SCAN,
  43. AMPROP_BITMAP_SCAN,
  44. AMPROP_BACKWARD_SCAN,
  45. AMPROP_CAN_ORDER, /* AM properties */
  46. AMPROP_CAN_UNIQUE,
  47. AMPROP_CAN_MULTI_COL,
  48. AMPROP_CAN_EXCLUDE,
  49. AMPROP_CAN_INCLUDE
  50. } IndexAMProperty;
  51. /*
  52. * Callback function signatures --- see indexam.sgml for more info.
  53. */
  54. /* build new index */
  55. typedef IndexBuildResult *(*ambuild_function) (Relation heapRelation,
  56. Relation indexRelation,
  57. struct IndexInfo *indexInfo);
  58. /* build empty index */
  59. typedef void (*ambuildempty_function) (Relation indexRelation);
  60. /* insert this tuple */
  61. typedef bool (*aminsert_function) (Relation indexRelation,
  62. Datum *values,
  63. bool *isnull,
  64. ItemPointer heap_tid,
  65. Relation heapRelation,
  66. IndexUniqueCheck checkUnique,
  67. struct IndexInfo *indexInfo);
  68. /* bulk delete */
  69. typedef IndexBulkDeleteResult *(*ambulkdelete_function) (IndexVacuumInfo *info,
  70. IndexBulkDeleteResult *stats,
  71. IndexBulkDeleteCallback callback,
  72. void *callback_state);
  73. /* post-VACUUM cleanup */
  74. typedef IndexBulkDeleteResult *(*amvacuumcleanup_function) (IndexVacuumInfo *info,
  75. IndexBulkDeleteResult *stats);
  76. /* can indexscan return IndexTuples? */
  77. typedef bool (*amcanreturn_function) (Relation indexRelation, int attno);
  78. /* estimate cost of an indexscan */
  79. typedef void (*amcostestimate_function) (struct PlannerInfo *root,
  80. struct IndexPath *path,
  81. double loop_count,
  82. Cost *indexStartupCost,
  83. Cost *indexTotalCost,
  84. Selectivity *indexSelectivity,
  85. double *indexCorrelation,
  86. double *indexPages);
  87. /* parse index reloptions */
  88. typedef bytea *(*amoptions_function) (Datum reloptions,
  89. bool validate);
  90. /* report AM, index, or index column property */
  91. typedef bool (*amproperty_function) (Oid index_oid, int attno,
  92. IndexAMProperty prop, const char *propname,
  93. bool *res, bool *isnull);
  94. /* name of phase as used in progress reporting */
  95. typedef char *(*ambuildphasename_function) (int64 phasenum);
  96. /* validate definition of an opclass for this AM */
  97. typedef bool (*amvalidate_function) (Oid opclassoid);
  98. /* prepare for index scan */
  99. typedef IndexScanDesc (*ambeginscan_function) (Relation indexRelation,
  100. int nkeys,
  101. int norderbys);
  102. /* (re)start index scan */
  103. typedef void (*amrescan_function) (IndexScanDesc scan,
  104. ScanKey keys,
  105. int nkeys,
  106. ScanKey orderbys,
  107. int norderbys);
  108. /* next valid tuple */
  109. typedef bool (*amgettuple_function) (IndexScanDesc scan,
  110. ScanDirection direction);
  111. /* fetch all valid tuples */
  112. typedef int64 (*amgetbitmap_function) (IndexScanDesc scan,
  113. TIDBitmap *tbm);
  114. /* end index scan */
  115. typedef void (*amendscan_function) (IndexScanDesc scan);
  116. /* mark current scan position */
  117. typedef void (*ammarkpos_function) (IndexScanDesc scan);
  118. /* restore marked scan position */
  119. typedef void (*amrestrpos_function) (IndexScanDesc scan);
  120. /*
  121. * Callback function signatures - for parallel index scans.
  122. */
  123. /* estimate size of parallel scan descriptor */
  124. typedef Size (*amestimateparallelscan_function) (void);
  125. /* prepare for parallel index scan */
  126. typedef void (*aminitparallelscan_function) (void *target);
  127. /* (re)start parallel index scan */
  128. typedef void (*amparallelrescan_function) (IndexScanDesc scan);
  129. /*
  130. * API struct for an index AM. Note this must be stored in a single palloc'd
  131. * chunk of memory.
  132. */
  133. typedef struct IndexAmRoutine
  134. {
  135. NodeTag type;
  136. /*
  137. * Total number of strategies (operators) by which we can traverse/search
  138. * this AM. Zero if AM does not have a fixed set of strategy assignments.
  139. */
  140. uint16 amstrategies;
  141. /* total number of support functions that this AM uses */
  142. uint16 amsupport;
  143. /* does AM support ORDER BY indexed column's value? */
  144. bool amcanorder;
  145. /* does AM support ORDER BY result of an operator on indexed column? */
  146. bool amcanorderbyop;
  147. /* does AM support backward scanning? */
  148. bool amcanbackward;
  149. /* does AM support UNIQUE indexes? */
  150. bool amcanunique;
  151. /* does AM support multi-column indexes? */
  152. bool amcanmulticol;
  153. /* does AM require scans to have a constraint on the first index column? */
  154. bool amoptionalkey;
  155. /* does AM handle ScalarArrayOpExpr quals? */
  156. bool amsearcharray;
  157. /* does AM handle IS NULL/IS NOT NULL quals? */
  158. bool amsearchnulls;
  159. /* can index storage data type differ from column data type? */
  160. bool amstorage;
  161. /* can an index of this type be clustered on? */
  162. bool amclusterable;
  163. /* does AM handle predicate locks? */
  164. bool ampredlocks;
  165. /* does AM support parallel scan? */
  166. bool amcanparallel;
  167. /* does AM support columns included with clause INCLUDE? */
  168. bool amcaninclude;
  169. /* type of data stored in index, or InvalidOid if variable */
  170. Oid amkeytype;
  171. /*
  172. * If you add new properties to either the above or the below lists, then
  173. * they should also (usually) be exposed via the property API (see
  174. * IndexAMProperty at the top of the file, and utils/adt/amutils.c).
  175. */
  176. /* interface functions */
  177. ambuild_function ambuild;
  178. ambuildempty_function ambuildempty;
  179. aminsert_function aminsert;
  180. ambulkdelete_function ambulkdelete;
  181. amvacuumcleanup_function amvacuumcleanup;
  182. amcanreturn_function amcanreturn; /* can be NULL */
  183. amcostestimate_function amcostestimate;
  184. amoptions_function amoptions;
  185. amproperty_function amproperty; /* can be NULL */
  186. ambuildphasename_function ambuildphasename; /* can be NULL */
  187. amvalidate_function amvalidate;
  188. ambeginscan_function ambeginscan;
  189. amrescan_function amrescan;
  190. amgettuple_function amgettuple; /* can be NULL */
  191. amgetbitmap_function amgetbitmap; /* can be NULL */
  192. amendscan_function amendscan;
  193. ammarkpos_function ammarkpos; /* can be NULL */
  194. amrestrpos_function amrestrpos; /* can be NULL */
  195. /* interface functions to support parallel index scans */
  196. amestimateparallelscan_function amestimateparallelscan; /* can be NULL */
  197. aminitparallelscan_function aminitparallelscan; /* can be NULL */
  198. amparallelrescan_function amparallelrescan; /* can be NULL */
  199. } IndexAmRoutine;
  200. /* Functions in access/index/amapi.c */
  201. extern IndexAmRoutine *GetIndexAmRoutine(Oid amhandler);
  202. extern IndexAmRoutine *GetIndexAmRoutineByAmId(Oid amoid, bool noerror);
  203. #endif /* AMAPI_H */
上海开阖软件有限公司 沪ICP备12045867号-1