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,
110  USERMAPPINGUSERSERVER
111 
112 #define SysCacheSize (USERMAPPINGUSERSERVER + 1)
113 };
114 
115 extern void InitCatalogCache(void);
116 extern void InitCatalogCachePhase2(void);
117 
118 extern HeapTuple SearchSysCache(int cacheId,
119  Datum key1, Datum key2, Datum key3, Datum key4);
120 
121 /*
122  * The use of argument specific numbers is encouraged. They're faster, and
123  * insulates the caller from changes in the maximum number of keys.
124  */
125 extern HeapTuple SearchSysCache1(int cacheId,
126  Datum key1);
127 extern HeapTuple SearchSysCache2(int cacheId,
128  Datum key1, Datum key2);
129 extern HeapTuple SearchSysCache3(int cacheId,
130  Datum key1, Datum key2, Datum key3);
131 extern HeapTuple SearchSysCache4(int cacheId,
132  Datum key1, Datum key2, Datum key3, Datum key4);
133 
134 extern void ReleaseSysCache(HeapTuple tuple);
135 
136 /* convenience routines */
137 extern HeapTuple SearchSysCacheCopy(int cacheId,
138  Datum key1, Datum key2, Datum key3, Datum key4);
139 extern bool SearchSysCacheExists(int cacheId,
140  Datum key1, Datum key2, Datum key3, Datum key4);
141 extern Oid GetSysCacheOid(int cacheId,
142  Datum key1, Datum key2, Datum key3, Datum key4);
143 
144 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
145 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
146 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
147 
148 extern HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum);
149 extern HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum);
150 
151 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
152  AttrNumber attributeNumber, bool *isNull);
153 
154 extern uint32 GetSysCacheHashValue(int cacheId,
155  Datum key1, Datum key2, Datum key3, Datum key4);
156 
157 /* list-search interface. Users of this must import catcache.h too */
158 struct catclist;
159 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
160  Datum key1, Datum key2, Datum key3, Datum key4);
161 
162 extern void SysCacheInvalidate(int cacheId, uint32 hashValue);
163 
164 extern bool RelationInvalidatesSnapshotsOnly(Oid relid);
165 extern bool RelationHasSysCache(Oid relid);
166 extern bool RelationSupportsSysCache(Oid relid);
167 
168 /*
169  * The use of the macros below rather than direct calls to the corresponding
170  * functions is encouraged, as it insulates the caller from changes in the
171  * maximum number of keys.
172  */
173 #define SearchSysCacheCopy1(cacheId, key1) \
174  SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
175 #define SearchSysCacheCopy2(cacheId, key1, key2) \
176  SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
177 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
178  SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
179 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
180  SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
181 
182 #define SearchSysCacheExists1(cacheId, key1) \
183  SearchSysCacheExists(cacheId, key1, 0, 0, 0)
184 #define SearchSysCacheExists2(cacheId, key1, key2) \
185  SearchSysCacheExists(cacheId, key1, key2, 0, 0)
186 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
187  SearchSysCacheExists(cacheId, key1, key2, key3, 0)
188 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
189  SearchSysCacheExists(cacheId, key1, key2, key3, key4)
190 
191 #define GetSysCacheOid1(cacheId, key1) \
192  GetSysCacheOid(cacheId, key1, 0, 0, 0)
193 #define GetSysCacheOid2(cacheId, key1, key2) \
194  GetSysCacheOid(cacheId, key1, key2, 0, 0)
195 #define GetSysCacheOid3(cacheId, key1, key2, key3) \
196  GetSysCacheOid(cacheId, key1, key2, key3, 0)
197 #define GetSysCacheOid4(cacheId, key1, key2, key3, key4) \
198  GetSysCacheOid(cacheId, key1, key2, key3, key4)
199 
200 #define GetSysCacheHashValue1(cacheId, key1) \
201  GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
202 #define GetSysCacheHashValue2(cacheId, key1, key2) \
203  GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
204 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
205  GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
206 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
207  GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
208 
209 #define SearchSysCacheList1(cacheId, key1) \
210  SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
211 #define SearchSysCacheList2(cacheId, key1, key2) \
212  SearchSysCacheList(cacheId, 2, key1, key2, 0, 0)
213 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
214  SearchSysCacheList(cacheId, 3, key1, key2, key3, 0)
215 #define SearchSysCacheList4(cacheId, key1, key2, key3, key4) \
216  SearchSysCacheList(cacheId, 4, key1, key2, key3, key4)
217 
218 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
219 
220 #endif /* SYSCACHE_H */
signed short int16
Definition: c.h:245
void SysCacheInvalidate(int cacheId, uint32 hashValue)
Definition: syscache.c:1440
Definition: syscache.h:36
void InitCatalogCache(void)
Definition: syscache.c:998
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1099
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1145
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1403
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:1487
Oid GetSysCacheOid(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1221
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:1271
HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1334
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1174
unsigned int Oid
Definition: postgres_ext.h:31
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1368
short nkeys
Definition: catcache.h:175
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1198
SysCacheIdentifier
Definition: syscache.h:32
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1464
unsigned int uint32
Definition: c.h:258
uintptr_t Datum
Definition: postgres.h:372
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1248
void InitCatalogCachePhase2(void)
Definition: syscache.c:1071
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1311
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:1512
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1420
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1134
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:1290
int16 AttrNumber
Definition: attnum.h:21