1 /*-------------------------------------------------------------------------
4 * This file provides some definitions to support indexing
8 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
9 * Portions Copyright (c) 1994, Regents of the University of California
11 * $Id: indexing.h,v 1.47 2001/01/24 19:43:20 momjian Exp $
13 *-------------------------------------------------------------------------
18 #include "access/htup.h"
21 * Number of indices that exist for each system catalog
23 #define Num_pg_aggregate_indices 1
24 #define Num_pg_am_indices 1
25 #define Num_pg_amop_indices 2
26 #define Num_pg_attr_indices 2
27 #define Num_pg_attrdef_indices 1
28 #define Num_pg_class_indices 2
29 #define Num_pg_description_indices 1
30 #define Num_pg_group_indices 2
31 #define Num_pg_index_indices 2
32 #define Num_pg_inherits_indices 1
33 #define Num_pg_language_indices 2
34 #define Num_pg_largeobject_indices 1
35 #define Num_pg_listener_indices 1
36 #define Num_pg_opclass_indices 2
37 #define Num_pg_operator_indices 2
38 #define Num_pg_proc_indices 2
39 #define Num_pg_relcheck_indices 1
40 #define Num_pg_rewrite_indices 2
41 #define Num_pg_shadow_indices 2
42 #define Num_pg_statistic_indices 1
43 #define Num_pg_trigger_indices 3
44 #define Num_pg_type_indices 2
47 * Names of indices on system catalogs
49 #define AccessMethodOpidIndex "pg_amop_opid_index"
50 #define AccessMethodStrategyIndex "pg_amop_strategy_index"
51 #define AggregateNameTypeIndex "pg_aggregate_name_type_index"
52 #define AmNameIndex "pg_am_name_index"
53 #define AttrDefaultIndex "pg_attrdef_adrelid_index"
54 #define AttributeRelidNameIndex "pg_attribute_relid_attnam_index"
55 #define AttributeRelidNumIndex "pg_attribute_relid_attnum_index"
56 #define ClassNameIndex "pg_class_relname_index"
57 #define ClassOidIndex "pg_class_oid_index"
58 #define DescriptionObjIndex "pg_description_objoid_index"
59 #define GroupNameIndex "pg_group_name_index"
60 #define GroupSysidIndex "pg_group_sysid_index"
61 #define IndexIndrelidIndex "pg_index_indrelid_index"
62 #define IndexRelidIndex "pg_index_indexrelid_index"
63 #define InheritsRelidSeqnoIndex "pg_inherits_relid_seqno_index"
64 #define LanguageNameIndex "pg_language_name_index"
65 #define LanguageOidIndex "pg_language_oid_index"
66 #define LargeObjectLOidPNIndex "pg_largeobject_loid_pn_index"
67 #define ListenerPidRelnameIndex "pg_listener_pid_relname_index"
68 #define OpclassDeftypeIndex "pg_opclass_deftype_index"
69 #define OpclassNameIndex "pg_opclass_name_index"
70 #define OperatorNameIndex "pg_operator_oprname_l_r_k_index"
71 #define OperatorOidIndex "pg_operator_oid_index"
72 #define ProcedureNameIndex "pg_proc_proname_narg_type_index"
73 #define ProcedureOidIndex "pg_proc_oid_index"
74 #define RelCheckIndex "pg_relcheck_rcrelid_index"
75 #define RewriteOidIndex "pg_rewrite_oid_index"
76 #define RewriteRulenameIndex "pg_rewrite_rulename_index"
77 #define ShadowNameIndex "pg_shadow_name_index"
78 #define ShadowSysidIndex "pg_shadow_sysid_index"
79 #define StatisticRelidAttnumIndex "pg_statistic_relid_att_index"
80 #define TriggerConstrNameIndex "pg_trigger_tgconstrname_index"
81 #define TriggerConstrRelidIndex "pg_trigger_tgconstrrelid_index"
82 #define TriggerRelidIndex "pg_trigger_tgrelid_index"
83 #define TypeNameIndex "pg_type_typname_index"
84 #define TypeOidIndex "pg_type_oid_index"
86 extern char *Name_pg_aggregate_indices[];
87 extern char *Name_pg_am_indices[];
88 extern char *Name_pg_amop_indices[];
89 extern char *Name_pg_attr_indices[];
90 extern char *Name_pg_attrdef_indices[];
91 extern char *Name_pg_class_indices[];
92 extern char *Name_pg_description_indices[];
93 extern char *Name_pg_group_indices[];
94 extern char *Name_pg_index_indices[];
95 extern char *Name_pg_inherits_indices[];
96 extern char *Name_pg_language_indices[];
97 extern char *Name_pg_largeobject_indices[];
98 extern char *Name_pg_listener_indices[];
99 extern char *Name_pg_opclass_indices[];
100 extern char *Name_pg_operator_indices[];
101 extern char *Name_pg_proc_indices[];
102 extern char *Name_pg_relcheck_indices[];
103 extern char *Name_pg_rewrite_indices[];
104 extern char *Name_pg_shadow_indices[];
105 extern char *Name_pg_statistic_indices[];
106 extern char *Name_pg_trigger_indices[];
107 extern char *Name_pg_type_indices[];
110 extern char *IndexedCatalogNames[];
113 * indexing.c prototypes
115 extern void CatalogOpenIndices(int nIndices, char **names, Relation *idescs);
116 extern void CatalogCloseIndices(int nIndices, Relation *idescs);
117 extern void CatalogIndexInsert(Relation *idescs, int nIndices,
118 Relation heapRelation, HeapTuple heapTuple);
121 * Canned functions for indexscans on certain system indexes.
122 * All index-value arguments should be passed as Datum for portability!
124 extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation,
125 Datum relid, Datum attnum);
126 extern HeapTuple ClassNameIndexScan(Relation heapRelation, Datum relName);
127 extern HeapTuple ClassOidIndexScan(Relation heapRelation, Datum relId);
131 * What follows are lines processed by genbki.sh to create the statements
132 * the bootstrap parser will turn into DefineIndex commands.
134 * The keyword is DECLARE_INDEX every thing after that is just like in a
135 * normal specification of the 'define index' POSTQUEL command.
138 DECLARE_UNIQUE_INDEX(pg_aggregate_name_type_index on pg_aggregate using btree(aggname name_ops, aggbasetype oid_ops));
139 DECLARE_UNIQUE_INDEX(pg_am_name_index on pg_am using btree(amname name_ops));
140 DECLARE_UNIQUE_INDEX(pg_amop_opid_index on pg_amop using btree(amopclaid oid_ops, amopopr oid_ops, amopid oid_ops));
141 DECLARE_UNIQUE_INDEX(pg_amop_strategy_index on pg_amop using btree(amopid oid_ops, amopclaid oid_ops, amopstrategy int2_ops));
142 /* This following index is not used for a cache and is not unique */
143 DECLARE_INDEX(pg_attrdef_adrelid_index on pg_attrdef using btree(adrelid oid_ops));
144 DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops));
145 DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
146 DECLARE_UNIQUE_INDEX(pg_class_oid_index on pg_class using btree(oid oid_ops));
147 DECLARE_UNIQUE_INDEX(pg_class_relname_index on pg_class using btree(relname name_ops));
148 DECLARE_UNIQUE_INDEX(pg_description_objoid_index on pg_description using btree(objoid oid_ops));
149 DECLARE_UNIQUE_INDEX(pg_group_name_index on pg_group using btree(groname name_ops));
150 DECLARE_UNIQUE_INDEX(pg_group_sysid_index on pg_group using btree(grosysid int4_ops));
151 /* This following index is not used for a cache and is not unique */
152 DECLARE_INDEX(pg_index_indrelid_index on pg_index using btree(indrelid oid_ops));
153 DECLARE_UNIQUE_INDEX(pg_index_indexrelid_index on pg_index using btree(indexrelid oid_ops));
154 DECLARE_UNIQUE_INDEX(pg_inherits_relid_seqno_index on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops));
155 DECLARE_UNIQUE_INDEX(pg_language_name_index on pg_language using btree(lanname name_ops));
156 DECLARE_UNIQUE_INDEX(pg_language_oid_index on pg_language using btree(oid oid_ops));
157 DECLARE_UNIQUE_INDEX(pg_largeobject_loid_pn_index on pg_largeobject using btree(loid oid_ops, pageno int4_ops));
158 DECLARE_UNIQUE_INDEX(pg_listener_pid_relname_index on pg_listener using btree(listenerpid int4_ops, relname name_ops));
159 /* This column needs to allow multiple zero entries, but is in the cache */
160 DECLARE_INDEX(pg_opclass_deftype_index on pg_opclass using btree(opcdeftype oid_ops));
161 DECLARE_UNIQUE_INDEX(pg_opclass_name_index on pg_opclass using btree(opcname name_ops));
162 DECLARE_UNIQUE_INDEX(pg_operator_oid_index on pg_operator using btree(oid oid_ops));
163 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));
164 DECLARE_UNIQUE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops));
165 DECLARE_UNIQUE_INDEX(pg_proc_proname_narg_type_index on pg_proc using btree(proname name_ops, pronargs int2_ops, proargtypes oidvector_ops));
166 /* This following index is not used for a cache and is not unique */
167 DECLARE_INDEX(pg_relcheck_rcrelid_index on pg_relcheck using btree(rcrelid oid_ops));
168 DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index on pg_rewrite using btree(oid oid_ops));
169 DECLARE_UNIQUE_INDEX(pg_rewrite_rulename_index on pg_rewrite using btree(rulename name_ops));
171 xDECLARE_UNIQUE_INDEX(pg_shadow_name_index on pg_shadow using btree(usename name_ops));
172 xDECLARE_UNIQUE_INDEX(pg_shadow_sysid_index on pg_shadow using btree(usesysid int4_ops));
174 DECLARE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(starelid oid_ops, staattnum int2_ops));
175 DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops));
176 DECLARE_INDEX(pg_trigger_tgconstrrelid_index on pg_trigger using btree(tgconstrrelid oid_ops));
177 DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops));
178 DECLARE_UNIQUE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops));
179 DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname name_ops));
181 /* now build indices in the initialization scripts */
184 #endif /* INDEXING_H */