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-2017, 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 
51 extern Oid index_create(Relation heapRelation,
52  const char *indexRelationName,
53  Oid indexRelationId,
54  Oid relFileNode,
55  IndexInfo *indexInfo,
56  List *indexColNames,
57  Oid accessMethodObjectId,
58  Oid tableSpaceId,
59  Oid *collationObjectId,
60  Oid *classObjectId,
61  int16 *coloptions,
62  Datum reloptions,
63  bits16 flags,
64  bits16 constr_flags,
65  bool allow_system_table_mods,
66  bool is_internal);
67 
68 #define INDEX_CONSTR_CREATE_MARK_AS_PRIMARY (1 << 0)
69 #define INDEX_CONSTR_CREATE_DEFERRABLE (1 << 1)
70 #define INDEX_CONSTR_CREATE_INIT_DEFERRED (1 << 2)
71 #define INDEX_CONSTR_CREATE_UPDATE_INDEX (1 << 3)
72 #define INDEX_CONSTR_CREATE_REMOVE_OLD_DEPS (1 << 4)
73 
75  Oid indexRelationId,
76  IndexInfo *indexInfo,
77  const char *constraintName,
78  char constraintType,
79  bits16 constr_flags,
80  bool allow_system_table_mods,
81  bool is_internal);
82 
83 extern void index_drop(Oid indexId, bool concurrent);
84 
86 
88 
89 extern void FormIndexDatum(IndexInfo *indexInfo,
90  TupleTableSlot *slot,
91  EState *estate,
92  Datum *values,
93  bool *isnull);
94 
95 extern void index_build(Relation heapRelation,
96  Relation indexRelation,
97  IndexInfo *indexInfo,
98  bool isprimary,
99  bool isreindex);
100 
101 extern double IndexBuildHeapScan(Relation heapRelation,
102  Relation indexRelation,
103  IndexInfo *indexInfo,
104  bool allow_sync,
106  void *callback_state);
107 extern double IndexBuildHeapRangeScan(Relation heapRelation,
108  Relation indexRelation,
109  IndexInfo *indexInfo,
110  bool allow_sync,
111  bool anyvisible,
112  BlockNumber start_blockno,
113  BlockNumber end_blockno,
115  void *callback_state);
116 
117 extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
118 
120 
121 extern void reindex_index(Oid indexId, bool skip_constraint_checks,
122  char relpersistence, int options);
123 
124 /* Flag bits for reindex_relation(): */
125 #define REINDEX_REL_PROCESS_TOAST 0x01
126 #define REINDEX_REL_SUPPRESS_INDEX_USE 0x02
127 #define REINDEX_REL_CHECK_CONSTRAINTS 0x04
128 #define REINDEX_REL_FORCE_INDEXES_UNLOGGED 0x08
129 #define REINDEX_REL_FORCE_INDEXES_PERMANENT 0x10
130 
131 extern bool reindex_relation(Oid relid, int flags, int options);
132 
133 extern bool ReindexIsProcessingHeap(Oid heapOid);
134 extern bool ReindexIsProcessingIndex(Oid indexOid);
135 extern Oid IndexGetRelation(Oid indexId, bool missing_ok);
136 
137 #endif /* INDEX_H */
signed short int16
Definition: c.h:293
double IndexBuildHeapScan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool allow_sync, IndexBuildCallback callback, void *callback_state)
Definition: index.c:2178
uint16 bits16
Definition: c.h:314
void reindex_index(Oid indexId, bool skip_constraint_checks, char relpersistence, int options)
Definition: index.c:3309
void index_check_primary_key(Relation heapRel, IndexInfo *indexInfo, bool is_alter_table)
Definition: index.c:195
uint32 BlockNumber
Definition: block.h:31
unsigned int Oid
Definition: postgres_ext.h:31
bool ReindexIsProcessingHeap(Oid heapOid)
Definition: index.c:3669
Oid index_create(Relation heapRelation, const char *indexRelationName, Oid indexRelationId, 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)
Definition: index.c:706
bool ReindexIsProcessingIndex(Oid indexOid)
Definition: index.c:3690
Definition: type.h:89
void validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
Definition: index.c:2808
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
IndexInfo * BuildIndexInfo(Relation index)
Definition: index.c:1645
IndexStateFlagsAction
Definition: index.h:32
void(* IndexBuildCallback)(Relation index, HeapTuple htup, Datum *values, bool *isnull, bool tupleIsAlive, void *state)
Definition: index.h:24
uintptr_t Datum
Definition: postgres.h:372
double IndexBuildHeapRangeScan(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool allow_sync, bool anyvisible, BlockNumber start_blockno, BlockNumber end_blockno, IndexBuildCallback callback, void *callback_state)
Definition: index.c:2203
ObjectAddress index_constraint_create(Relation heapRelation, Oid indexRelationId, IndexInfo *indexInfo, const char *constraintName, char constraintType, bits16 constr_flags, bool allow_system_table_mods, bool is_internal)
Definition: index.c:1149
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isprimary, bool isreindex)
Definition: index.c:2009
Definition: regguts.h:298
Oid IndexGetRelation(Oid indexId, bool missing_ok)
Definition: index.c:3284
void index_drop(Oid indexId, bool concurrent)
Definition: index.c:1350
static Datum values[MAXATTR]
Definition: bootstrap.c:164
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
Definition: index.c:1774
bool reindex_relation(Oid relid, int flags, int options)
Definition: index.c:3518
Definition: pg_list.h:45
void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
Definition: index.c:1716
void index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
Definition: index.c:3205