1 /*-------------------------------------------------------------------------
4 * prototypes for catalog/index.c.
7 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/catalog/index.h
12 *-------------------------------------------------------------------------
17 #include "catalog/objectaddress.h"
18 #include "nodes/execnodes.h"
21 #define DEFAULT_INDEX_TYPE "btree"
23 /* Typedef for callback function for IndexBuildHeapScan */
24 typedef void (*IndexBuildCallback) (Relation index,
31 /* Action code for index_set_state_flags */
34 INDEX_CREATE_SET_READY,
35 INDEX_CREATE_SET_VALID,
36 INDEX_DROP_CLEAR_VALID,
38 } IndexStateFlagsAction;
41 extern void index_check_primary_key(Relation heapRel,
46 #define INDEX_CREATE_IS_PRIMARY (1 << 0)
47 #define INDEX_CREATE_ADD_CONSTRAINT (1 << 1)
48 #define INDEX_CREATE_SKIP_BUILD (1 << 2)
49 #define INDEX_CREATE_CONCURRENT (1 << 3)
50 #define INDEX_CREATE_IF_NOT_EXISTS (1 << 4)
51 #define INDEX_CREATE_PARTITIONED (1 << 5)
52 #define INDEX_CREATE_INVALID (1 << 6)
54 extern Oid index_create(Relation heapRelation,
55 const char *indexRelationName,
58 Oid parentConstraintId,
62 Oid accessMethodObjectId,
64 Oid *collationObjectId,
70 bool allow_system_table_mods,
74 #define INDEX_CONSTR_CREATE_MARK_AS_PRIMARY (1 << 0)
75 #define INDEX_CONSTR_CREATE_DEFERRABLE (1 << 1)
76 #define INDEX_CONSTR_CREATE_INIT_DEFERRED (1 << 2)
77 #define INDEX_CONSTR_CREATE_UPDATE_INDEX (1 << 3)
78 #define INDEX_CONSTR_CREATE_REMOVE_OLD_DEPS (1 << 4)
80 extern ObjectAddress index_constraint_create(Relation heapRelation,
82 Oid parentConstraintId,
84 const char *constraintName,
87 bool allow_system_table_mods,
90 extern void index_drop(Oid indexId, bool concurrent);
92 extern IndexInfo *BuildIndexInfo(Relation index);
94 extern bool CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
95 Oid *collations1, Oid *collations2,
96 Oid *opfamilies1, Oid *opfamilies2,
97 AttrNumber *attmap, int maplen);
99 extern void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii);
101 extern void FormIndexDatum(IndexInfo *indexInfo,
102 TupleTableSlot *slot,
107 extern void index_build(Relation heapRelation,
108 Relation indexRelation,
109 IndexInfo *indexInfo,
113 extern double IndexBuildHeapScan(Relation heapRelation,
114 Relation indexRelation,
115 IndexInfo *indexInfo,
117 IndexBuildCallback callback,
118 void *callback_state,
119 struct HeapScanDescData *scan);
120 extern double IndexBuildHeapRangeScan(Relation heapRelation,
121 Relation indexRelation,
122 IndexInfo *indexInfo,
125 BlockNumber start_blockno,
126 BlockNumber end_blockno,
127 IndexBuildCallback callback,
128 void *callback_state,
129 struct HeapScanDescData *scan);
131 extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
133 extern void index_set_state_flags(Oid indexId, IndexStateFlagsAction action);
135 extern void reindex_index(Oid indexId, bool skip_constraint_checks,
136 char relpersistence, int options);
138 /* Flag bits for reindex_relation(): */
139 #define REINDEX_REL_PROCESS_TOAST 0x01
140 #define REINDEX_REL_SUPPRESS_INDEX_USE 0x02
141 #define REINDEX_REL_CHECK_CONSTRAINTS 0x04
142 #define REINDEX_REL_FORCE_INDEXES_UNLOGGED 0x08
143 #define REINDEX_REL_FORCE_INDEXES_PERMANENT 0x10
145 extern bool reindex_relation(Oid relid, int flags, int options);
147 extern bool ReindexIsProcessingHeap(Oid heapOid);
148 extern bool ReindexIsProcessingIndex(Oid indexOid);
149 extern Oid IndexGetRelation(Oid indexId, bool missing_ok);
151 extern Size EstimateReindexStateSpace(void);
152 extern void SerializeReindexState(Size maxsize, char *start_address);
153 extern void RestoreReindexState(void *reindexstate);
155 extern void IndexSetParentIndex(Relation idx, Oid parentOid);