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