PostgreSQL Source Code  git master
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-2022, 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,
116  USERMAPPINGUSERSERVER
117 
118 #define SysCacheSize (USERMAPPINGUSERSERVER + 1)
119 };
120 
121 extern void InitCatalogCache(void);
122 extern void InitCatalogCachePhase2(void);
123 
124 extern HeapTuple SearchSysCache(int cacheId,
125  Datum key1, Datum key2, Datum key3, Datum key4);
126 
127 /*
128  * The use of argument specific numbers is encouraged. They're faster, and
129  * insulates the caller from changes in the maximum number of keys.
130  */
131 extern HeapTuple SearchSysCache1(int cacheId,
132  Datum key1);
133 extern HeapTuple SearchSysCache2(int cacheId,
134  Datum key1, Datum key2);
135 extern HeapTuple SearchSysCache3(int cacheId,
136  Datum key1, Datum key2, Datum key3);
137 extern HeapTuple SearchSysCache4(int cacheId,
138  Datum key1, Datum key2, Datum key3, Datum key4);
139 
140 extern void ReleaseSysCache(HeapTuple tuple);
141 
142 /* convenience routines */
143 extern HeapTuple SearchSysCacheCopy(int cacheId,
144  Datum key1, Datum key2, Datum key3, Datum key4);
145 extern bool SearchSysCacheExists(int cacheId,
146  Datum key1, Datum key2, Datum key3, Datum key4);
147 extern Oid GetSysCacheOid(int cacheId, AttrNumber oidcol,
148  Datum key1, Datum key2, Datum key3, Datum key4);
149 
150 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
151 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
152 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
153 
156 
157 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
158  AttrNumber attributeNumber, bool *isNull);
159 
160 extern uint32 GetSysCacheHashValue(int cacheId,
161  Datum key1, Datum key2, Datum key3, Datum key4);
162 
163 /* list-search interface. Users of this must import catcache.h too */
164 struct catclist;
165 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
166  Datum key1, Datum key2, Datum key3);
167 
168 extern void SysCacheInvalidate(int cacheId, uint32 hashValue);
169 
170 extern bool RelationInvalidatesSnapshotsOnly(Oid relid);
171 extern bool RelationHasSysCache(Oid relid);
172 extern bool RelationSupportsSysCache(Oid relid);
173 
174 /*
175  * The use of the macros below rather than direct calls to the corresponding
176  * functions is encouraged, as it insulates the caller from changes in the
177  * maximum number of keys.
178  */
179 #define SearchSysCacheCopy1(cacheId, key1) \
180  SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
181 #define SearchSysCacheCopy2(cacheId, key1, key2) \
182  SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
183 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
184  SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
185 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
186  SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
187 
188 #define SearchSysCacheExists1(cacheId, key1) \
189  SearchSysCacheExists(cacheId, key1, 0, 0, 0)
190 #define SearchSysCacheExists2(cacheId, key1, key2) \
191  SearchSysCacheExists(cacheId, key1, key2, 0, 0)
192 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
193  SearchSysCacheExists(cacheId, key1, key2, key3, 0)
194 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
195  SearchSysCacheExists(cacheId, key1, key2, key3, key4)
196 
197 #define GetSysCacheOid1(cacheId, oidcol, key1) \
198  GetSysCacheOid(cacheId, oidcol, key1, 0, 0, 0)
199 #define GetSysCacheOid2(cacheId, oidcol, key1, key2) \
200  GetSysCacheOid(cacheId, oidcol, key1, key2, 0, 0)
201 #define GetSysCacheOid3(cacheId, oidcol, key1, key2, key3) \
202  GetSysCacheOid(cacheId, oidcol, key1, key2, key3, 0)
203 #define GetSysCacheOid4(cacheId, oidcol, key1, key2, key3, key4) \
204  GetSysCacheOid(cacheId, oidcol, key1, key2, key3, key4)
205 
206 #define GetSysCacheHashValue1(cacheId, key1) \
207  GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
208 #define GetSysCacheHashValue2(cacheId, key1, key2) \
209  GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
210 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
211  GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
212 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
213  GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
214 
215 #define SearchSysCacheList1(cacheId, key1) \
216  SearchSysCacheList(cacheId, 1, key1, 0, 0)
217 #define SearchSysCacheList2(cacheId, key1, key2) \
218  SearchSysCacheList(cacheId, 2, key1, key2, 0)
219 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
220  SearchSysCacheList(cacheId, 3, key1, key2, key3)
221 
222 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
223 
224 #endif /* SYSCACHE_H */
int16 AttrNumber
Definition: attnum.h:21
unsigned int uint32
Definition: c.h:442
signed short int16
Definition: c.h:429
NameData attname
Definition: pg_attribute.h:41
int16 attnum
Definition: pg_attribute.h:83
uintptr_t Datum
Definition: postgres.h:412
unsigned int Oid
Definition: postgres_ext.h:31
short nkeys
Definition: catcache.h:175
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:1337
void SysCacheInvalidate(int cacheId, uint32 hashValue)
Definition: syscache.c:1506
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:1553
SysCacheIdentifier
Definition: syscache.h:33
@ FOREIGNTABLEREL
Definition: syscache.h:65
@ PARAMETERACLOID
Definition: syscache.h:76
@ RULERELNAME
Definition: syscache.h:92
@ FOREIGNSERVEROID
Definition: syscache.h:64
@ FOREIGNSERVERNAME
Definition: syscache.h:63
@ RANGETYPE
Definition: syscache.h:87
@ TSTEMPLATEOID
Definition: syscache.h:112
@ TSDICTOID
Definition: syscache.h:108
@ OPFAMILYOID
Definition: syscache.h:74
@ STATRELATTINH
Definition: syscache.h:97
@ PUBLICATIONREL
Definition: syscache.h:84
@ REPLORIGIDENT
Definition: syscache.h:90
@ CONNAMENSP
Definition: syscache.h:52
@ SUBSCRIPTIONNAME
Definition: syscache.h:98
@ STATEXTOID
Definition: syscache.h:96
@ TSPARSERNAMENSP
Definition: syscache.h:109
@ OPERNAMENSP
Definition: syscache.h:71
@ TYPEOID
Definition: syscache.h:114
@ TRFTYPELANG
Definition: syscache.h:103
@ AGGFNOID
Definition: syscache.h:34
@ AMNAME
Definition: syscache.h:35
@ AMOID
Definition: syscache.h:36
@ OPEROID
Definition: syscache.h:72
@ TSTEMPLATENAMENSP
Definition: syscache.h:111
@ PROCOID
Definition: syscache.h:79
@ RANGEMULTIRANGE
Definition: syscache.h:86
@ CONDEFAULT
Definition: syscache.h:51
@ AUTHOID
Definition: syscache.h:45
@ EVENTTRIGGEROID
Definition: syscache.h:60
@ TSCONFIGMAP
Definition: syscache.h:104
@ TSCONFIGNAMENSP
Definition: syscache.h:105
@ STATEXTNAMENSP
Definition: syscache.h:95
@ ATTNAME
Definition: syscache.h:40
@ INDEXRELID
Definition: syscache.h:66
@ AUTHNAME
Definition: syscache.h:44
@ PUBLICATIONOID
Definition: syscache.h:83
@ CONVOID
Definition: syscache.h:54
@ ATTNUM
Definition: syscache.h:41
@ RELOID
Definition: syscache.h:89
@ SUBSCRIPTIONRELMAP
Definition: syscache.h:100
@ PUBLICATIONNAME
Definition: syscache.h:80
@ PUBLICATIONNAMESPACE
Definition: syscache.h:81
@ RELNAMENSP
Definition: syscache.h:88
@ TABLESPACEOID
Definition: syscache.h:101
@ CASTSOURCETARGET
Definition: syscache.h:46
@ TYPENAMENSP
Definition: syscache.h:113
@ COLLOID
Definition: syscache.h:50
@ COLLNAMEENCNSP
Definition: syscache.h:49
@ TRFOID
Definition: syscache.h:102
@ CLAOID
Definition: syscache.h:48
@ AUTHMEMROLEMEM
Definition: syscache.h:43
@ ENUMTYPOIDNAME
Definition: syscache.h:58
@ PUBLICATIONNAMESPACEMAP
Definition: syscache.h:82
@ PUBLICATIONRELMAP
Definition: syscache.h:85
@ SUBSCRIPTIONOID
Definition: syscache.h:99
@ LANGNAME
Definition: syscache.h:67
@ EVENTTRIGGERNAME
Definition: syscache.h:59
@ PARAMETERACLNAME
Definition: syscache.h:75
@ FOREIGNDATAWRAPPEROID
Definition: syscache.h:62
@ USERMAPPINGOID
Definition: syscache.h:115
@ REPLORIGNAME
Definition: syscache.h:91
@ AUTHMEMMEMROLE
Definition: syscache.h:42
@ DEFACLROLENSPOBJ
Definition: syscache.h:56
@ AMOPOPID
Definition: syscache.h:37
@ CLAAMNAMENSP
Definition: syscache.h:47
@ DATABASEOID
Definition: syscache.h:55
@ OPFAMILYAMNAMENSP
Definition: syscache.h:73
@ AMPROCNUM
Definition: syscache.h:39
@ FOREIGNDATAWRAPPERNAME
Definition: syscache.h:61
@ ENUMOID
Definition: syscache.h:57
@ AMOPSTRATEGY
Definition: syscache.h:38
@ TSPARSEROID
Definition: syscache.h:110
@ PARTRELID
Definition: syscache.h:77
@ PROCNAMEARGSNSP
Definition: syscache.h:78
@ TSCONFIGOID
Definition: syscache.h:106
@ TSDICTNAMENSP
Definition: syscache.h:107
@ LANGOID
Definition: syscache.h:68
@ NAMESPACEOID
Definition: syscache.h:70
@ CONSTROID
Definition: syscache.h:53
@ STATEXTDATASTXOID
Definition: syscache.h:94
@ NAMESPACENAME
Definition: syscache.h:69
@ SEQRELID
Definition: syscache.h:93
HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1400
void InitCatalogCache(void)
Definition: syscache.c:1067
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1221
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1160
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1173
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1469
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1486
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1195
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1377
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:1578
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1434
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:1356
void InitCatalogCachePhase2(void)
Definition: syscache.c:1132
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1184
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1314
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1259
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1235
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1530
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1206
Oid GetSysCacheOid(int cacheId, AttrNumber oidcol, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1282