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-2023, 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 Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup,
161  AttrNumber attributeNumber);
162 
163 extern uint32 GetSysCacheHashValue(int cacheId,
164  Datum key1, Datum key2, Datum key3, Datum key4);
165 
166 /* list-search interface. Users of this must import catcache.h too */
167 struct catclist;
168 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
169  Datum key1, Datum key2, Datum key3);
170 
171 extern void SysCacheInvalidate(int cacheId, uint32 hashValue);
172 
173 extern bool RelationInvalidatesSnapshotsOnly(Oid relid);
174 extern bool RelationHasSysCache(Oid relid);
175 extern bool RelationSupportsSysCache(Oid relid);
176 
177 /*
178  * The use of the macros below rather than direct calls to the corresponding
179  * functions is encouraged, as it insulates the caller from changes in the
180  * maximum number of keys.
181  */
182 #define SearchSysCacheCopy1(cacheId, key1) \
183  SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
184 #define SearchSysCacheCopy2(cacheId, key1, key2) \
185  SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
186 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
187  SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
188 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
189  SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
190 
191 #define SearchSysCacheExists1(cacheId, key1) \
192  SearchSysCacheExists(cacheId, key1, 0, 0, 0)
193 #define SearchSysCacheExists2(cacheId, key1, key2) \
194  SearchSysCacheExists(cacheId, key1, key2, 0, 0)
195 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
196  SearchSysCacheExists(cacheId, key1, key2, key3, 0)
197 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
198  SearchSysCacheExists(cacheId, key1, key2, key3, key4)
199 
200 #define GetSysCacheOid1(cacheId, oidcol, key1) \
201  GetSysCacheOid(cacheId, oidcol, key1, 0, 0, 0)
202 #define GetSysCacheOid2(cacheId, oidcol, key1, key2) \
203  GetSysCacheOid(cacheId, oidcol, key1, key2, 0, 0)
204 #define GetSysCacheOid3(cacheId, oidcol, key1, key2, key3) \
205  GetSysCacheOid(cacheId, oidcol, key1, key2, key3, 0)
206 #define GetSysCacheOid4(cacheId, oidcol, key1, key2, key3, key4) \
207  GetSysCacheOid(cacheId, oidcol, key1, key2, key3, key4)
208 
209 #define GetSysCacheHashValue1(cacheId, key1) \
210  GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
211 #define GetSysCacheHashValue2(cacheId, key1, key2) \
212  GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
213 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
214  GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
215 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
216  GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
217 
218 #define SearchSysCacheList1(cacheId, key1) \
219  SearchSysCacheList(cacheId, 1, key1, 0, 0)
220 #define SearchSysCacheList2(cacheId, key1, key2) \
221  SearchSysCacheList(cacheId, 2, key1, key2, 0)
222 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
223  SearchSysCacheList(cacheId, 3, key1, key2, key3)
224 
225 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
226 
227 #endif /* SYSCACHE_H */
int16 AttrNumber
Definition: attnum.h:21
unsigned int uint32
Definition: c.h:495
signed short int16
Definition: c.h:482
NameData attname
Definition: pg_attribute.h:41
int16 attnum
Definition: pg_attribute.h:74
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
short nkeys
Definition: catcache.h:175
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:984
void SysCacheInvalidate(int cacheId, uint32 hashValue)
Definition: syscache.c:1179
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:1226
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:1047
void InitCatalogCache(void)
Definition: syscache.c:709
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:868
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:807
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:820
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1142
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1159
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:842
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1024
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:1251
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1081
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:1003
void InitCatalogCachePhase2(void)
Definition: syscache.c:779
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:831
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:961
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:906
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:882
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1203
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:853
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition: syscache.c:1112
Oid GetSysCacheOid(int cacheId, AttrNumber oidcol, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:929