]> granicus.if.org Git - postgresql/blob - src/include/catalog/index.h
Remove argument isprimary from index_build()
[postgresql] / src / include / catalog / index.h
1 /*-------------------------------------------------------------------------
2  *
3  * index.h
4  *        prototypes for catalog/index.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2019, 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 */
24 typedef void (*IndexBuildCallback) (Relation index,
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 {
34         INDEX_CREATE_SET_READY,
35         INDEX_CREATE_SET_VALID,
36         INDEX_DROP_CLEAR_VALID,
37         INDEX_DROP_SET_DEAD
38 } IndexStateFlagsAction;
39
40
41 extern void index_check_primary_key(Relation heapRel,
42                                                 IndexInfo *indexInfo,
43                                                 bool is_alter_table,
44                                                 IndexStmt *stmt);
45
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)
53
54 extern Oid index_create(Relation heapRelation,
55                          const char *indexRelationName,
56                          Oid indexRelationId,
57                          Oid parentIndexRelid,
58                          Oid parentConstraintId,
59                          Oid relFileNode,
60                          IndexInfo *indexInfo,
61                          List *indexColNames,
62                          Oid accessMethodObjectId,
63                          Oid tableSpaceId,
64                          Oid *collationObjectId,
65                          Oid *classObjectId,
66                          int16 *coloptions,
67                          Datum reloptions,
68                          bits16 flags,
69                          bits16 constr_flags,
70                          bool allow_system_table_mods,
71                          bool is_internal,
72                          Oid *constraintId);
73
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)
79
80 extern ObjectAddress index_constraint_create(Relation heapRelation,
81                                                 Oid indexRelationId,
82                                                 Oid parentConstraintId,
83                                                 IndexInfo *indexInfo,
84                                                 const char *constraintName,
85                                                 char constraintType,
86                                                 bits16 constr_flags,
87                                                 bool allow_system_table_mods,
88                                                 bool is_internal);
89
90 extern void index_drop(Oid indexId, bool concurrent);
91
92 extern IndexInfo *BuildIndexInfo(Relation index);
93
94 extern bool CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
95                                  Oid *collations1, Oid *collations2,
96                                  Oid *opfamilies1, Oid *opfamilies2,
97                                  AttrNumber *attmap, int maplen);
98
99 extern void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii);
100
101 extern void FormIndexDatum(IndexInfo *indexInfo,
102                            TupleTableSlot *slot,
103                            EState *estate,
104                            Datum *values,
105                            bool *isnull);
106
107 extern void index_build(Relation heapRelation,
108                         Relation indexRelation,
109                         IndexInfo *indexInfo,
110                         bool isreindex,
111                         bool parallel);
112
113 extern double IndexBuildHeapScan(Relation heapRelation,
114                                    Relation indexRelation,
115                                    IndexInfo *indexInfo,
116                                    bool allow_sync,
117                                    IndexBuildCallback callback,
118                                    void *callback_state,
119                                    struct HeapScanDescData *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,
127                                                 IndexBuildCallback callback,
128                                                 void *callback_state,
129                                                 struct HeapScanDescData *scan);
130
131 extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
132
133 extern void index_set_state_flags(Oid indexId, IndexStateFlagsAction action);
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 */