PostgreSQL Source Code  git master
index.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * index.h
4  * prototypes for catalog/index.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2018, 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 
17 #include "catalog/objectaddress.h"
18 #include "nodes/execnodes.h"
19 
20 
21 #define DEFAULT_INDEX_TYPE "btree"
22 
23 /* Typedef for callback function for IndexBuildHeapScan */
25  HeapTuple htup,
26  Datum *values,
27  bool *isnull,
28  bool tupleIsAlive,
29  void *state);
30 
31 /* Action code for index_set_state_flags */
32 typedef enum
33 {
39 
40 
41 extern void index_check_primary_key(Relation heapRel,
42  IndexInfo *indexInfo,
43  bool is_alter_table);
44 
45 #define INDEX_CREATE_IS_PRIMARY (1 << 0)
46 #define INDEX_CREATE_ADD_CONSTRAINT (1 << 1)
47 #define INDEX_CREATE_SKIP_BUILD (1 << 2)
48 #define INDEX_CREATE_CONCURRENT (1 << 3)
49 #define INDEX_CREATE_IF_NOT_EXISTS (1 << 4)
50 #define INDEX_CREATE_PARTITIONED (1 << 5)
51 #define INDEX_CREATE_INVALID (1 << 6)
52 
53 extern Oid index_create(Relation heapRelation,
54  const char *indexRelationName,
55  Oid indexRelationId,
56  Oid parentIndexRelid,
57  Oid parentConstraintId,
58  Oid relFileNode,
59  IndexInfo *indexInfo,
60  List *indexColNames,
61  Oid accessMethodObjectId,
62  Oid tableSpaceId,
63  Oid *collationObjectId,
64  Oid *classObjectId,
65  int16 *coloptions,
66  Datum reloptions,
67  bits16 flags,
68  bits16 constr_flags,
69  bool allow_system_table_mods,
70  bool is_internal,
71  Oid *constraintId);
72 
73 #define INDEX_CONSTR_CREATE_MARK_AS_PRIMARY (1 << 0)
74 #define INDEX_CONSTR_CREATE_DEFERRABLE (1 << 1)
75 #define INDEX_CONSTR_CREATE_INIT_DEFERRED (1 << 2)
76 #define INDEX_CONSTR_CREATE_UPDATE_INDEX (1 << 3)
77 #define INDEX_CONSTR_CREATE_REMOVE_OLD_DEPS (1 << 4)
78 
80  Oid indexRelationId,
81  Oid parentConstraintId,
82  IndexInfo *indexInfo,
83  const char *constraintName,
84  char constraintType,
85  bits16 constr_flags,
86  bool allow_system_table_mods,
87  bool is_internal);
88 
89 extern void index_drop(Oid indexId, bool concurrent);
90 
92 
93 extern bool CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
94  Oid *collations1, Oid *collations2,
95  Oid *opfamilies1, Oid *opfamilies2,
96  AttrNumber *attmap, int maplen);
97 
99 
100 extern void FormIndexDatum(IndexInfo *indexInfo,
101  TupleTableSlot *slot,
102  EState *estate,
103  Datum *values,
104  bool *isnull);
105 
106 extern void index_build(Relation heapRelation,
107  Relation indexRelation,
108  IndexInfo *indexInfo,
109  bool isprimary,
110  bool isreindex,
111  bool parallel);
112 
113 extern double IndexBuildHeapScan(Relation heapRelation,
114  Relation indexRelation,
115  IndexInfo *indexInfo,
116  bool allow_sync,
118  void *callback_state,
119  HeapScanDesc scan);
120 extern double IndexBuildHeapRangeScan(Relation heapRelation,
121  Relation indexRelation,
122  IndexInfo *indexInfo,
123  bool allow_sync,
124  bool anyvisible,
125  BlockNumber start_blockno,
126  BlockNumber end_blockno,
128  void *callback_state,
129  HeapScanDesc scan);
130 
131 extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
132 
134 
135 extern void reindex_index(Oid indexId, bool skip_constraint_checks,
136  char relpersistence, int options);
137 
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
144 
145 extern bool reindex_relation(Oid relid, int flags, int options);
146 
147 extern bool ReindexIsProcessingHeap(Oid heapOid);
148 extern bool ReindexIsProcessingIndex(Oid indexOid);
149 extern Oid IndexGetRelation(Oid indexId, bool missing_ok);
150 
151 extern Size EstimateReindexStateSpace(void);
152 extern void SerializeReindexState(Size maxsize, char *start_address);
153 extern void RestoreReindexState(void *reindexstate);
154 
155 extern void IndexSetParentIndex(Relation idx, Oid parentOid);
156 
157 #endif /* INDEX_H */
signed short int16
Definition: c.h:312
ObjectAddress index_constraint_create(Relation heapRelation, Oid indexRelationId, Oid parentConstraintId, IndexInfo *indexInfo, const char *constraintName, char constraintType, bits16 constr_flags, bool allow_system_table_mods, bool is_internal)
Definition: index.c:1225
uint16 bits16
Definition: c.h:333
void reindex_index(Oid indexId, bool skip_constraint_checks, char relpersistence, int options)
Definition: index.c:3617
void IndexSetParentIndex(Relation idx, Oid parentOid)
Definition: indexcmds.c:2467
void index_check_primary_key(Relation heapRel, IndexInfo *indexInfo, bool is_alter_table)
Definition: index.c:213
Oid index_create(Relation heapRelation, const char *indexRelationName, Oid indexRelationId, Oid parentIndexRelid, Oid parentConstraintId, Oid relFileNode, IndexInfo *indexInfo, List *indexColNames, Oid accessMethodObjectId, Oid tableSpaceId, Oid *collationObjectId, Oid *classObjectId, int16 *coloptions, Datum reloptions, bits16 flags, bits16 constr_flags, bool allow_system_table_mods, bool is_internal, Oid *constraintId)
Definition: index.c:745
Datum idx(PG_FUNCTION_ARGS)
Definition: _int_op.c:264
uint32 BlockNumber
Definition: block.h:31
unsigned int Oid
Definition: postgres_ext.h:31
bool ReindexIsProcessingHeap(Oid heapOid)
Definition: index.c:4002
bool ReindexIsProcessingIndex(Oid indexOid)
Definition: index.c:4023
Definition: type.h:89
void validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
Definition: index.c:3114
char relpersistence
Definition: pg_class.h:50
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
bool CompareIndexInfo(IndexInfo *info1, IndexInfo *info2, Oid *collations1, Oid *collations2, Oid *opfamilies1, Oid *opfamilies2, AttrNumber *attmap, int maplen)
Definition: index.c:1820
IndexInfo * BuildIndexInfo(Relation index)
Definition: index.c:1745
IndexStateFlagsAction
Definition: index.h:32
double IndexBuildHeapScan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool allow_sync, IndexBuildCallback callback, void *callback_state, HeapScanDesc scan)
Definition: index.c:2418
double IndexBuildHeapRangeScan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool allow_sync, bool anyvisible, BlockNumber start_blockno, BlockNumber end_blockno, IndexBuildCallback callback, void *callback_state, HeapScanDesc scan)
Definition: index.c:2444
void(* IndexBuildCallback)(Relation index, HeapTuple htup, Datum *values, bool *isnull, bool tupleIsAlive, void *state)
Definition: index.h:24
void RestoreReindexState(void *reindexstate)
Definition: index.c:4136
uintptr_t Datum
Definition: postgres.h:367
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isprimary, bool isreindex, bool parallel)
Definition: index.c:2229
Definition: regguts.h:298
size_t Size
Definition: c.h:433
Size EstimateReindexStateSpace(void)
Definition: index.c:4107
Oid IndexGetRelation(Oid indexId, bool missing_ok)
Definition: index.c:3592
void index_drop(Oid indexId, bool concurrent)
Definition: index.c:1443
static Datum values[MAXATTR]
Definition: bootstrap.c:164
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
Definition: index.c:2000
bool reindex_relation(Oid relid, int flags, int options)
Definition: index.c:3834
void SerializeReindexState(Size maxsize, char *start_address)
Definition: index.c:4118
Definition: pg_list.h:45
void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
Definition: index.c:1940
int16 AttrNumber
Definition: attnum.h:21
void index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
Definition: index.c:3513