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-2017, 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 intentionally 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,
111 };
112 
113 extern void InitCatalogCache(void);
114 extern void InitCatalogCachePhase2(void);
115 
116 extern HeapTuple SearchSysCache(int cacheId,
117  Datum key1, Datum key2, Datum key3, Datum key4);
118 extern void ReleaseSysCache(HeapTuple tuple);
119 
120 /* convenience routines */
121 extern HeapTuple SearchSysCacheCopy(int cacheId,
122  Datum key1, Datum key2, Datum key3, Datum key4);
123 extern bool SearchSysCacheExists(int cacheId,
124  Datum key1, Datum key2, Datum key3, Datum key4);
125 extern Oid GetSysCacheOid(int cacheId,
126  Datum key1, Datum key2, Datum key3, Datum key4);
127 
128 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
129 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
130 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
131 
132 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
133  AttrNumber attributeNumber, bool *isNull);
134 
135 extern uint32 GetSysCacheHashValue(int cacheId,
136  Datum key1, Datum key2, Datum key3, Datum key4);
137 
138 /* list-search interface. Users of this must import catcache.h too */
139 struct catclist;
140 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
141  Datum key1, Datum key2, Datum key3, Datum key4);
142 
143 extern bool RelationInvalidatesSnapshotsOnly(Oid relid);
144 extern bool RelationHasSysCache(Oid relid);
145 extern bool RelationSupportsSysCache(Oid relid);
146 
147 /*
148  * The use of the macros below rather than direct calls to the corresponding
149  * functions is encouraged, as it insulates the caller from changes in the
150  * maximum number of keys.
151  */
152 #define SearchSysCache1(cacheId, key1) \
153  SearchSysCache(cacheId, key1, 0, 0, 0)
154 #define SearchSysCache2(cacheId, key1, key2) \
155  SearchSysCache(cacheId, key1, key2, 0, 0)
156 #define SearchSysCache3(cacheId, key1, key2, key3) \
157  SearchSysCache(cacheId, key1, key2, key3, 0)
158 #define SearchSysCache4(cacheId, key1, key2, key3, key4) \
159  SearchSysCache(cacheId, key1, key2, key3, key4)
160 
161 #define SearchSysCacheCopy1(cacheId, key1) \
162  SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
163 #define SearchSysCacheCopy2(cacheId, key1, key2) \
164  SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
165 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
166  SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
167 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
168  SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
169 
170 #define SearchSysCacheExists1(cacheId, key1) \
171  SearchSysCacheExists(cacheId, key1, 0, 0, 0)
172 #define SearchSysCacheExists2(cacheId, key1, key2) \
173  SearchSysCacheExists(cacheId, key1, key2, 0, 0)
174 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
175  SearchSysCacheExists(cacheId, key1, key2, key3, 0)
176 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
177  SearchSysCacheExists(cacheId, key1, key2, key3, key4)
178 
179 #define GetSysCacheOid1(cacheId, key1) \
180  GetSysCacheOid(cacheId, key1, 0, 0, 0)
181 #define GetSysCacheOid2(cacheId, key1, key2) \
182  GetSysCacheOid(cacheId, key1, key2, 0, 0)
183 #define GetSysCacheOid3(cacheId, key1, key2, key3) \
184  GetSysCacheOid(cacheId, key1, key2, key3, 0)
185 #define GetSysCacheOid4(cacheId, key1, key2, key3, key4) \
186  GetSysCacheOid(cacheId, key1, key2, key3, key4)
187 
188 #define GetSysCacheHashValue1(cacheId, key1) \
189  GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
190 #define GetSysCacheHashValue2(cacheId, key1, key2) \
191  GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
192 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
193  GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
194 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
195  GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
196 
197 #define SearchSysCacheList1(cacheId, key1) \
198  SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
199 #define SearchSysCacheList2(cacheId, key1, key2) \
200  SearchSysCacheList(cacheId, 2, key1, key2, 0, 0)
201 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
202  SearchSysCacheList(cacheId, 3, key1, key2, key3, 0)
203 #define SearchSysCacheList4(cacheId, key1, key2, key3, key4) \
204  SearchSysCacheList(cacheId, 4, key1, key2, key3, key4)
205 
206 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
207 
208 #endif /* SYSCACHE_H */
Definition: syscache.h:36
void InitCatalogCache(void)
Definition: syscache.c:1000
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1098
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1313
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:1376
Oid GetSysCacheOid(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1177
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:1227
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1130
unsigned int Oid
Definition: postgres_ext.h:31
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1278
short nkeys
Definition: catcache.h:151
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1154
SysCacheIdentifier
Definition: syscache.h:32
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1353
unsigned int uint32
Definition: c.h:268
uintptr_t Datum
Definition: postgres.h:372
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1204
void InitCatalogCachePhase2(void)
Definition: syscache.c:1070
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:1401
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1330
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:1246
int16 AttrNumber
Definition: attnum.h:21