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