]> granicus.if.org Git - postgresql/blob - src/include/catalog/index.h
Reorganize our CRC source files again.
[postgresql] / src / include / catalog / index.h
1 /*-------------------------------------------------------------------------
2  *
3  * index.h
4  *        prototypes for catalog/index.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2015, 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
45 extern Oid index_create(Relation heapRelation,
46                          const char *indexRelationName,
47                          Oid indexRelationId,
48                          Oid relFileNode,
49                          IndexInfo *indexInfo,
50                          List *indexColNames,
51                          Oid accessMethodObjectId,
52                          Oid tableSpaceId,
53                          Oid *collationObjectId,
54                          Oid *classObjectId,
55                          int16 *coloptions,
56                          Datum reloptions,
57                          bool isprimary,
58                          bool isconstraint,
59                          bool deferrable,
60                          bool initdeferred,
61                          bool allow_system_table_mods,
62                          bool skip_build,
63                          bool concurrent,
64                          bool is_internal,
65                          bool if_not_exists);
66
67 extern ObjectAddress index_constraint_create(Relation heapRelation,
68                                                 Oid indexRelationId,
69                                                 IndexInfo *indexInfo,
70                                                 const char *constraintName,
71                                                 char constraintType,
72                                                 bool deferrable,
73                                                 bool initdeferred,
74                                                 bool mark_as_primary,
75                                                 bool update_pgindex,
76                                                 bool remove_old_dependencies,
77                                                 bool allow_system_table_mods,
78                                                 bool is_internal);
79
80 extern void index_drop(Oid indexId, bool concurrent);
81
82 extern IndexInfo *BuildIndexInfo(Relation index);
83
84 extern void FormIndexDatum(IndexInfo *indexInfo,
85                            TupleTableSlot *slot,
86                            EState *estate,
87                            Datum *values,
88                            bool *isnull);
89
90 extern void index_build(Relation heapRelation,
91                         Relation indexRelation,
92                         IndexInfo *indexInfo,
93                         bool isprimary,
94                         bool isreindex);
95
96 extern double IndexBuildHeapScan(Relation heapRelation,
97                                    Relation indexRelation,
98                                    IndexInfo *indexInfo,
99                                    bool allow_sync,
100                                    IndexBuildCallback callback,
101                                    void *callback_state);
102 extern double IndexBuildHeapRangeScan(Relation heapRelation,
103                                                 Relation indexRelation,
104                                                 IndexInfo *indexInfo,
105                                                 bool allow_sync,
106                                                 BlockNumber start_blockno,
107                                                 BlockNumber end_blockno,
108                                                 IndexBuildCallback callback,
109                                                 void *callback_state);
110
111 extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
112
113 extern void index_set_state_flags(Oid indexId, IndexStateFlagsAction action);
114
115 extern void reindex_index(Oid indexId, bool skip_constraint_checks,
116                           char relpersistence);
117
118 /* Flag bits for reindex_relation(): */
119 #define REINDEX_REL_PROCESS_TOAST                       0x01
120 #define REINDEX_REL_SUPPRESS_INDEX_USE          0x02
121 #define REINDEX_REL_CHECK_CONSTRAINTS           0x04
122 #define REINDEX_REL_FORCE_INDEXES_UNLOGGED      0x08
123 #define REINDEX_REL_FORCE_INDEXES_PERMANENT     0x10
124
125 extern bool reindex_relation(Oid relid, int flags);
126
127 extern bool ReindexIsProcessingHeap(Oid heapOid);
128 extern bool ReindexIsProcessingIndex(Oid indexOid);
129 extern Oid      IndexGetRelation(Oid indexId, bool missing_ok);
130
131 #endif   /* INDEX_H */