index.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*-------------------------------------------------------------------------
  2. *
  3. * index.h
  4. * prototypes for catalog/index.c.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/catalog/index.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef INDEX_H
  15. #define INDEX_H
  16. #include "catalog/objectaddress.h"
  17. #include "nodes/execnodes.h"
  18. #define DEFAULT_INDEX_TYPE "btree"
  19. /* Typedef for callback function for IndexBuildHeapScan */
  20. typedef void (*IndexBuildCallback) (Relation index,
  21. HeapTuple htup,
  22. Datum *values,
  23. bool *isnull,
  24. bool tupleIsAlive,
  25. void *state);
  26. /* Action code for index_set_state_flags */
  27. typedef enum
  28. {
  29. INDEX_CREATE_SET_READY,
  30. INDEX_CREATE_SET_VALID,
  31. INDEX_DROP_CLEAR_VALID,
  32. INDEX_DROP_SET_DEAD
  33. } IndexStateFlagsAction;
  34. extern void index_check_primary_key(Relation heapRel,
  35. IndexInfo *indexInfo,
  36. bool is_alter_table);
  37. extern Oid index_create(Relation heapRelation,
  38. const char *indexRelationName,
  39. Oid indexRelationId,
  40. Oid relFileNode,
  41. IndexInfo *indexInfo,
  42. List *indexColNames,
  43. Oid accessMethodObjectId,
  44. Oid tableSpaceId,
  45. Oid *collationObjectId,
  46. Oid *classObjectId,
  47. int16 *coloptions,
  48. Datum reloptions,
  49. bool isprimary,
  50. bool isconstraint,
  51. bool deferrable,
  52. bool initdeferred,
  53. bool allow_system_table_mods,
  54. bool skip_build,
  55. bool concurrent,
  56. bool is_internal,
  57. bool if_not_exists);
  58. extern ObjectAddress index_constraint_create(Relation heapRelation,
  59. Oid indexRelationId,
  60. IndexInfo *indexInfo,
  61. const char *constraintName,
  62. char constraintType,
  63. bool deferrable,
  64. bool initdeferred,
  65. bool mark_as_primary,
  66. bool update_pgindex,
  67. bool remove_old_dependencies,
  68. bool allow_system_table_mods,
  69. bool is_internal);
  70. extern void index_drop(Oid indexId, bool concurrent);
  71. extern IndexInfo *BuildIndexInfo(Relation index);
  72. extern void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii);
  73. extern void FormIndexDatum(IndexInfo *indexInfo,
  74. TupleTableSlot *slot,
  75. EState *estate,
  76. Datum *values,
  77. bool *isnull);
  78. extern void index_build(Relation heapRelation,
  79. Relation indexRelation,
  80. IndexInfo *indexInfo,
  81. bool isprimary,
  82. bool isreindex);
  83. extern double IndexBuildHeapScan(Relation heapRelation,
  84. Relation indexRelation,
  85. IndexInfo *indexInfo,
  86. bool allow_sync,
  87. IndexBuildCallback callback,
  88. void *callback_state);
  89. extern double IndexBuildHeapRangeScan(Relation heapRelation,
  90. Relation indexRelation,
  91. IndexInfo *indexInfo,
  92. bool allow_sync,
  93. bool anyvisible,
  94. BlockNumber start_blockno,
  95. BlockNumber end_blockno,
  96. IndexBuildCallback callback,
  97. void *callback_state);
  98. extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
  99. extern void index_set_state_flags(Oid indexId, IndexStateFlagsAction action);
  100. extern void reindex_index(Oid indexId, bool skip_constraint_checks,
  101. char relpersistence, int options);
  102. /* Flag bits for reindex_relation(): */
  103. #define REINDEX_REL_PROCESS_TOAST 0x01
  104. #define REINDEX_REL_SUPPRESS_INDEX_USE 0x02
  105. #define REINDEX_REL_CHECK_CONSTRAINTS 0x04
  106. #define REINDEX_REL_FORCE_INDEXES_UNLOGGED 0x08
  107. #define REINDEX_REL_FORCE_INDEXES_PERMANENT 0x10
  108. extern bool reindex_relation(Oid relid, int flags, int options);
  109. extern bool ReindexIsProcessingHeap(Oid heapOid);
  110. extern bool ReindexIsProcessingIndex(Oid indexOid);
  111. extern Oid IndexGetRelation(Oid indexId, bool missing_ok);
  112. #endif /* INDEX_H */