1 /*-------------------------------------------------------------------------
4 * System catalog cache definitions.
6 * See also lsyscache.h, which provides convenience routines for
7 * common cache-lookup operations.
9 * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
10 * Portions Copyright (c) 1994, Regents of the University of California
12 * src/include/utils/syscache.h
14 *-------------------------------------------------------------------------
19 #include "access/attnum.h"
20 #include "access/htup.h"
21 /* we purposedly do not include utils/catcache.h here */
24 * SysCache identifiers.
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
32 enum SysCacheIdentifier
61 FOREIGNDATAWRAPPERNAME,
62 FOREIGNDATAWRAPPEROID,
98 extern void InitCatalogCache(void);
99 extern void InitCatalogCachePhase2(void);
101 extern HeapTuple SearchSysCache(int cacheId,
102 Datum key1, Datum key2, Datum key3, Datum key4);
103 extern void ReleaseSysCache(HeapTuple tuple);
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);
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);
117 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
118 AttrNumber attributeNumber, bool *isNull);
120 extern uint32 GetSysCacheHashValue(int cacheId,
121 Datum key1, Datum key2, Datum key3, Datum key4);
123 /* list-search interface. Users of this must import catcache.h too */
125 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
126 Datum key1, Datum key2, Datum key3, Datum key4);
128 extern bool RelationInvalidatesSnapshotsOnly(Oid);
129 extern bool RelationHasSysCache(Oid);
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.
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)
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)
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)
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)
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)
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)
190 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
192 #endif /* SYSCACHE_H */