]> granicus.if.org Git - postgresql/blob - src/include/catalog/indexing.h
Update for index change. Semes it didn't work the first time.
[postgresql] / src / include / catalog / indexing.h
1 /*-------------------------------------------------------------------------
2  *
3  * indexing.h
4  *        This include provides some definitions to support indexing
5  *        on system catalogs
6  *
7  *
8  * Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: indexing.h,v 1.35 2000/01/24 03:08:27 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef INDEXING_H
15 #define INDEXING_H
16
17 #include "access/htup.h"
18
19 /*
20  * Some definitions for indices on pg_attribute
21  */
22 #define Num_pg_aggregate_indices        1
23 #define Num_pg_am_indices                       1
24 #define Num_pg_amop_indices                     2
25 #define Num_pg_attr_indices                     2
26 #define Num_pg_attrdef_indices          1
27 #define Num_pg_class_indices            2
28 #define Num_pg_description_indices      1
29 #define Num_pg_group_indices            2
30 #define Num_pg_index_indices            1
31 #define Num_pg_inherits_indices         1
32 #define Num_pg_language_indices         2
33 #define Num_pg_listener_indices         1
34 #define Num_pg_opclass_indices          2
35 #define Num_pg_operator_indices         2
36 #define Num_pg_proc_indices                     2
37 #define Num_pg_relcheck_indices         1
38 #define Num_pg_rewrite_indices          2
39 #define Num_pg_shadow_indices           2
40 #define Num_pg_statistic_indices        1
41 #define Num_pg_trigger_indices          3
42 #define Num_pg_type_indices                     2
43
44
45 /*
46  * Names of indices on system catalogs
47  */
48 #define AccessMethodOpidIndex           "pg_amop_opid_index"
49 #define AccessMethodStrategyIndex       "pg_amop_strategy_index"
50 #define AggregateNameTypeIndex          "pg_aggregate_name_type_index"
51 #define AmNameIndex                                     "pg_am_name_index"
52 #define AttrDefaultIndex                        "pg_attrdef_adrelid_index"
53 #define AttributeRelidNameIndex         "pg_attribute_relid_attnam_index"
54 #define AttributeRelidNumIndex          "pg_attribute_relid_attnum_index"
55 #define ClassNameIndex                          "pg_class_relname_index"
56 #define ClassOidIndex                           "pg_class_oid_index"
57 #define DescriptionObjIndex                     "pg_description_objoid_index"
58 #define GroupNameIndex                          "pg_group_name_index"
59 #define GroupSysidIndex                         "pg_group_sysid_index"
60 #define IndexRelidIndex                         "pg_index_indexrelid_index"
61 #define InheritsRelidSeqnoIndex         "pg_inherits_relid_seqno_index"
62 #define LanguageNameIndex                       "pg_language_name_index"
63 #define LanguageOidIndex                        "pg_language_oid_index"
64 #define ListenerRelnamePidIndex         "pg_listener_relname_pid_index"
65 #define OpclassDeftypeIndex                     "pg_opclass_deftype_index"
66 #define OpclassNameIndex                        "pg_opclass_name_index"
67 #define OperatorNameIndex                       "pg_operator_oprname_l_r_k_index"
68 #define OperatorOidIndex                        "pg_operator_oid_index"
69 #define ProcedureNameIndex                      "pg_proc_proname_narg_type_index"
70 #define ProcedureOidIndex                       "pg_proc_oid_index"
71 #define RelCheckIndex                           "pg_relcheck_rcrelid_index"
72 #define RewriteOidIndex                         "pg_rewrite_oid_index"
73 #define RewriteRulenameIndex            "pg_rewrite_rulename_index"
74 #define ShadowNameIndex                         "pg_shadow_name_index"
75 #define ShadowSysidIndex                        "pg_shadow_sysid_index"
76 #define StatisticRelidAttnumIndex       "pg_statistic_relid_att_index"
77 #define TriggerConstrNameIndex          "pg_trigger_tgconstrname_index"
78 #define TriggerConstrRelidIndex         "pg_trigger_tgconstrrelid_index"
79 #define TriggerRelidIndex                       "pg_trigger_tgrelid_index"
80 #define TypeNameIndex                           "pg_type_typname_index"
81 #define TypeOidIndex                            "pg_type_oid_index"
82
83 extern char *Name_pg_aggregate_indices[];
84 extern char *Name_pg_am_indices[];
85 extern char *Name_pg_amop_indices[];
86 extern char *Name_pg_attr_indices[];
87 extern char *Name_pg_attrdef_indices[];
88 extern char *Name_pg_class_indices[];
89 extern char *Name_pg_description_indices[];
90 extern char *Name_pg_group_indices[];
91 extern char *Name_pg_index_indices[];
92 extern char *Name_pg_inherits_indices[];
93 extern char *Name_pg_language_indices[];
94 extern char *Name_pg_listener_indices[];
95 extern char *Name_pg_opclass_indices[];
96 extern char *Name_pg_operator_indices[];
97 extern char *Name_pg_proc_indices[];
98 extern char *Name_pg_relcheck_indices[];
99 extern char *Name_pg_rewrite_indices[];
100 extern char *Name_pg_shadow_indices[];
101 extern char *Name_pg_statistic_indices[];
102 extern char *Name_pg_trigger_indices[];
103 extern char *Name_pg_type_indices[];
104
105
106 extern char *IndexedCatalogNames[];
107
108 /*
109  * indexing.c prototypes
110  *
111  * Functions for each index to perform the necessary scan on a cache miss.
112  */
113 extern void CatalogOpenIndices(int nIndices, char **names, Relation *idescs);
114 extern void CatalogCloseIndices(int nIndices, Relation *idescs);
115 extern void CatalogIndexInsert(Relation *idescs,
116                                         int nIndices,
117                                         Relation heapRelation,
118                                         HeapTuple heapTuple);
119 extern bool CatalogHasIndex(char *catName, Oid catId);
120
121 extern HeapTuple AccessMethodOpidIndexScan(Relation heapRelation,
122                                         Oid claid, Oid opopr, Oid opid);
123 extern HeapTuple AccessMethodStrategyIndexScan(Relation heapRelation,
124                                         Oid opid, Oid claid, int2 opstrategy);
125 extern HeapTuple AggregateNameTypeIndexScan(Relation heapRelation,
126                                         char *aggName, Oid aggType);
127 extern HeapTuple AmNameIndexScan(Relation heapRelation, char *amName);
128 extern HeapTuple AttributeRelidNameIndexScan(Relation heapRelation,
129                                         Oid relid, char *attname);
130 extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation,
131                                         Oid relid, AttrNumber attnum);
132 extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName);
133 extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName);
134 extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId);
135 extern HeapTuple GroupNameIndexScan(Relation heapRelation, char *groName);
136 extern HeapTuple GroupSysidIndexScan(Relation heapRelation, int4 sysId);
137 extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Oid relid);
138 extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid,
139                                         int4 seqno);
140 extern HeapTuple LanguageNameIndexScan(Relation heapRelation, char *lanName);
141 extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Oid lanId);
142 extern HeapTuple ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid);
143 extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Oid defType);
144 extern HeapTuple OpclassNameIndexScan(Relation heapRelation, char *opcName);
145 extern HeapTuple OperatorNameIndexScan(Relation heapRelation,
146                                         char *oprName, Oid oprLeft, Oid oprRight, char oprKind);
147 extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Oid oprId);
148 extern HeapTuple ProcedureNameIndexScan(Relation heapRelation,
149                                         char *procName, int2 nargs, Oid *argTypes);
150 extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId);
151 extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Oid rewriteId);
152 extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation,
153                                         char *ruleName);
154 extern HeapTuple ShadowNameIndexScan(Relation heapRelation, char *useName);
155 extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, int4 sysId);
156 extern HeapTuple StatisticRelidAttnumIndexScan(Relation heapRelation,
157                                  Oid relId, AttrNumber attNum);
158 extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName);
159 extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId);
160
161
162
163
164 /*
165  * What follows are lines processed by genbki.sh to create the statements
166  * the bootstrap parser will turn into DefineIndex commands.
167  *
168  * The keyword is DECLARE_INDEX every thing after that is just like in a
169  * normal specification of the 'define index' POSTQUEL command.
170  */
171
172 DECLARE_UNIQUE_INDEX(pg_aggregate_name_type_index on pg_aggregate using btree(aggname name_ops, aggbasetype oid_ops));
173 DECLARE_UNIQUE_INDEX(pg_am_name_index on pg_am using btree(amname name_ops));
174 DECLARE_UNIQUE_INDEX(pg_amop_opid_index on pg_amop using btree(amopclaid oid_ops, amopopr oid_ops, amopid oid_ops));
175 DECLARE_UNIQUE_INDEX(pg_amop_strategy_index on pg_amop using btree(amopid oid_ops, amopclaid oid_ops, amopstrategy int2_ops));
176 /* This following index is not used for a cache and is not unique */
177 DECLARE_INDEX(pg_attrdef_adrelid_index on pg_attrdef using btree(adrelid oid_ops));
178 DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops));
179 DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
180 DECLARE_UNIQUE_INDEX(pg_class_oid_index on pg_class using btree(oid oid_ops));
181 DECLARE_UNIQUE_INDEX(pg_class_relname_index on pg_class using btree(relname name_ops));
182 DECLARE_UNIQUE_INDEX(pg_description_objoid_index on pg_description using btree(objoid oid_ops));
183 DECLARE_UNIQUE_INDEX(pg_group_name_index on pg_group using btree(groname name_ops));
184 DECLARE_UNIQUE_INDEX(pg_group_sysid_index on pg_group using btree(grosysid int4_ops));
185 DECLARE_UNIQUE_INDEX(pg_index_indexrelid_index on pg_index using btree(indexrelid oid_ops));
186 DECLARE_UNIQUE_INDEX(pg_inherits_relid_seqno_index on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops));
187 DECLARE_UNIQUE_INDEX(pg_language_name_index on pg_language using btree(lanname name_ops));
188 DECLARE_UNIQUE_INDEX(pg_language_oid_index on pg_language using btree(oid oid_ops));
189 DECLARE_UNIQUE_INDEX(pg_listener_relname_pid_index on pg_listener using btree(relname name_ops, listenerpid int4_ops));
190 /* This column needs to allow multiple zero entries, but is in the cache */
191 DECLARE_INDEX(pg_opclass_deftype_index on pg_opclass using btree(opcdeftype oid_ops));
192 DECLARE_UNIQUE_INDEX(pg_opclass_name_index on pg_opclass using btree(opcname name_ops));
193 DECLARE_UNIQUE_INDEX(pg_operator_oid_index on pg_operator using btree(oid oid_ops));
194 DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_k_index on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprkind char_ops));
195 DECLARE_UNIQUE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops));
196 DECLARE_UNIQUE_INDEX(pg_proc_proname_narg_type_index on pg_proc using btree(proname name_ops, pronargs int2_ops, proargtypes oidvector_ops));
197 /* This following index is not used for a cache and is not unique */
198 DECLARE_INDEX(pg_relcheck_rcrelid_index on pg_relcheck using btree(rcrelid oid_ops));
199 DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index on pg_rewrite using btree(oid oid_ops));
200 DECLARE_UNIQUE_INDEX(pg_rewrite_rulename_index on pg_rewrite using btree(rulename name_ops));
201 /*
202 xDECLARE_UNIQUE_INDEX(pg_shadow_name_index on pg_shadow using btree(usename name_ops));
203 xDECLARE_UNIQUE_INDEX(pg_shadow_sysid_index on pg_shadow using btree(usesysid int4_ops));
204 */
205 DECLARE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(starelid oid_ops, staattnum int2_ops));
206 DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops));
207 DECLARE_INDEX(pg_trigger_tgconstrrelid_index on pg_trigger using btree(tgconstrrelid oid_ops));
208 DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops));
209 DECLARE_UNIQUE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops));
210 DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname name_ops));
211
212 /* now build indices in the initialization scripts */
213 BUILD_INDICES
214
215 #endif   /* INDEXING_H */