PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
syscache.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * syscache.h
4  * System catalog cache definitions.
5  *
6  * See also lsyscache.h, which provides convenience routines for
7  * common cache-lookup operations.
8  *
9  * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
10  * Portions Copyright (c) 1994, Regents of the University of California
11  *
12  * src/include/utils/syscache.h
13  *
14  *-------------------------------------------------------------------------
15  */
16 #ifndef SYSCACHE_H
17 #define SYSCACHE_H
18 
19 #include "access/attnum.h"
20 #include "access/htup.h"
21 /* we purposedly do not include utils/catcache.h here */
22 
23 /*
24  * SysCache identifiers.
25  *
26  * The order of these identifiers must match the order
27  * of the entries in the array cacheinfo[] in syscache.c.
28  * Keep them in alphabetical order (renumbering only costs a
29  * backend rebuild).
30  */
31 
33 {
34  AGGFNOID = 0,
96 };
97 
98 extern void InitCatalogCache(void);
99 extern void InitCatalogCachePhase2(void);
100 
101 extern HeapTuple SearchSysCache(int cacheId,
102  Datum key1, Datum key2, Datum key3, Datum key4);
103 extern void ReleaseSysCache(HeapTuple tuple);
104 
105 /* convenience routines */
106 extern HeapTuple SearchSysCacheCopy(int cacheId,
107  Datum key1, Datum key2, Datum key3, Datum key4);
108 extern bool SearchSysCacheExists(int cacheId,
109  Datum key1, Datum key2, Datum key3, Datum key4);
110 extern Oid GetSysCacheOid(int cacheId,
111  Datum key1, Datum key2, Datum key3, Datum key4);
112 
113 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
114 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
115 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
116 
117 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
118  AttrNumber attributeNumber, bool *isNull);
119 
120 extern uint32 GetSysCacheHashValue(int cacheId,
121  Datum key1, Datum key2, Datum key3, Datum key4);
122 
123 /* list-search interface. Users of this must import catcache.h too */
124 struct catclist;
125 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
126  Datum key1, Datum key2, Datum key3, Datum key4);
127 
129 extern bool RelationHasSysCache(Oid);
130 
131 /*
132  * The use of the macros below rather than direct calls to the corresponding
133  * functions is encouraged, as it insulates the caller from changes in the
134  * maximum number of keys.
135  */
136 #define SearchSysCache1(cacheId, key1) \
137  SearchSysCache(cacheId, key1, 0, 0, 0)
138 #define SearchSysCache2(cacheId, key1, key2) \
139  SearchSysCache(cacheId, key1, key2, 0, 0)
140 #define SearchSysCache3(cacheId, key1, key2, key3) \
141  SearchSysCache(cacheId, key1, key2, key3, 0)
142 #define SearchSysCache4(cacheId, key1, key2, key3, key4) \
143  SearchSysCache(cacheId, key1, key2, key3, key4)
144 
145 #define SearchSysCacheCopy1(cacheId, key1) \
146  SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
147 #define SearchSysCacheCopy2(cacheId, key1, key2) \
148  SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
149 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
150  SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
151 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
152  SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
153 
154 #define SearchSysCacheExists1(cacheId, key1) \
155  SearchSysCacheExists(cacheId, key1, 0, 0, 0)
156 #define SearchSysCacheExists2(cacheId, key1, key2) \
157  SearchSysCacheExists(cacheId, key1, key2, 0, 0)
158 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
159  SearchSysCacheExists(cacheId, key1, key2, key3, 0)
160 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
161  SearchSysCacheExists(cacheId, key1, key2, key3, key4)
162 
163 #define GetSysCacheOid1(cacheId, key1) \
164  GetSysCacheOid(cacheId, key1, 0, 0, 0)
165 #define GetSysCacheOid2(cacheId, key1, key2) \
166  GetSysCacheOid(cacheId, key1, key2, 0, 0)
167 #define GetSysCacheOid3(cacheId, key1, key2, key3) \
168  GetSysCacheOid(cacheId, key1, key2, key3, 0)
169 #define GetSysCacheOid4(cacheId, key1, key2, key3, key4) \
170  GetSysCacheOid(cacheId, key1, key2, key3, key4)
171 
172 #define GetSysCacheHashValue1(cacheId, key1) \
173  GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
174 #define GetSysCacheHashValue2(cacheId, key1, key2) \
175  GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
176 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
177  GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
178 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
179  GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
180 
181 #define SearchSysCacheList1(cacheId, key1) \
182  SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
183 #define SearchSysCacheList2(cacheId, key1, key2) \
184  SearchSysCacheList(cacheId, 2, key1, key2, 0, 0)
185 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
186  SearchSysCacheList(cacheId, 3, key1, key2, key3, 0)
187 #define SearchSysCacheList4(cacheId, key1, key2, key3, key4) \
188  SearchSysCacheList(cacheId, 4, key1, key2, key3, key4)
189 
190 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
191 
192 #endif /* SYSCACHE_H */