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-2024, 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 #include "catalog/syscache_ids.h"
24 
25 extern void InitCatalogCache(void);
26 extern void InitCatalogCachePhase2(void);
27 
28 extern HeapTuple SearchSysCache(int cacheId,
29  Datum key1, Datum key2, Datum key3, Datum key4);
30 
31 /*
32  * The use of argument specific numbers is encouraged. They're faster, and
33  * insulates the caller from changes in the maximum number of keys.
34  */
35 extern HeapTuple SearchSysCache1(int cacheId,
36  Datum key1);
37 extern HeapTuple SearchSysCache2(int cacheId,
38  Datum key1, Datum key2);
39 extern HeapTuple SearchSysCache3(int cacheId,
40  Datum key1, Datum key2, Datum key3);
41 extern HeapTuple SearchSysCache4(int cacheId,
42  Datum key1, Datum key2, Datum key3, Datum key4);
43 
44 extern void ReleaseSysCache(HeapTuple tuple);
45 
46 /* convenience routines */
47 extern HeapTuple SearchSysCacheCopy(int cacheId,
48  Datum key1, Datum key2, Datum key3, Datum key4);
49 extern bool SearchSysCacheExists(int cacheId,
50  Datum key1, Datum key2, Datum key3, Datum key4);
51 extern Oid GetSysCacheOid(int cacheId, AttrNumber oidcol,
52  Datum key1, Datum key2, Datum key3, Datum key4);
53 
54 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
55 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
56 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
57 
60 
61 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
62  AttrNumber attributeNumber, bool *isNull);
63 
64 extern Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup,
65  AttrNumber attributeNumber);
66 
67 extern uint32 GetSysCacheHashValue(int cacheId,
68  Datum key1, Datum key2, Datum key3, Datum key4);
69 
70 /* list-search interface. Users of this must import catcache.h too */
71 struct catclist;
72 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
73  Datum key1, Datum key2, Datum key3);
74 
75 extern void SysCacheInvalidate(int cacheId, uint32 hashValue);
76 
77 extern bool RelationInvalidatesSnapshotsOnly(Oid relid);
78 extern bool RelationHasSysCache(Oid relid);
79 extern bool RelationSupportsSysCache(Oid relid);
80 
81 /*
82  * The use of the macros below rather than direct calls to the corresponding
83  * functions is encouraged, as it insulates the caller from changes in the
84  * maximum number of keys.
85  */
86 #define SearchSysCacheCopy1(cacheId, key1) \
87  SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
88 #define SearchSysCacheCopy2(cacheId, key1, key2) \
89  SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
90 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
91  SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
92 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
93  SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
94 
95 #define SearchSysCacheExists1(cacheId, key1) \
96  SearchSysCacheExists(cacheId, key1, 0, 0, 0)
97 #define SearchSysCacheExists2(cacheId, key1, key2) \
98  SearchSysCacheExists(cacheId, key1, key2, 0, 0)
99 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
100  SearchSysCacheExists(cacheId, key1, key2, key3, 0)
101 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
102  SearchSysCacheExists(cacheId, key1, key2, key3, key4)
103 
104 #define GetSysCacheOid1(cacheId, oidcol, key1) \
105  GetSysCacheOid(cacheId, oidcol, key1, 0, 0, 0)
106 #define GetSysCacheOid2(cacheId, oidcol, key1, key2) \
107  GetSysCacheOid(cacheId, oidcol, key1, key2, 0, 0)
108 #define GetSysCacheOid3(cacheId, oidcol, key1, key2, key3) \
109  GetSysCacheOid(cacheId, oidcol, key1, key2, key3, 0)
110 #define GetSysCacheOid4(cacheId, oidcol, key1, key2, key3, key4) \
111  GetSysCacheOid(cacheId, oidcol, key1, key2, key3, key4)
112 
113 #define GetSysCacheHashValue1(cacheId, key1) \
114  GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
115 #define GetSysCacheHashValue2(cacheId, key1, key2) \
116  GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
117 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
118  GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
119 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
120  GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
121 
122 #define SearchSysCacheList1(cacheId, key1) \
123  SearchSysCacheList(cacheId, 1, key1, 0, 0)
124 #define SearchSysCacheList2(cacheId, key1, key2) \
125  SearchSysCacheList(cacheId, 2, key1, key2, 0)
126 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
127  SearchSysCacheList(cacheId, 3, key1, key2, key3)
128 
129 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
130 
131 #endif /* SYSCACHE_H */
int16 AttrNumber
Definition: attnum.h:21
unsigned int uint32
Definition: c.h:506
signed short int16
Definition: c.h:493
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:177
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:382
void SysCacheInvalidate(int cacheId, uint32 hashValue)
Definition: syscache.c:577
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:624
HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
Definition: syscache.c:445
void InitCatalogCache(void)
Definition: syscache.c:107
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:266
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:205
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:218
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:540
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:557
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:240
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:422
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:649
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:479
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:401
void InitCatalogCachePhase2(void)
Definition: syscache.c:177
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:229
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:359
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:304
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:280
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:601
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:251
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition: syscache.c:510
Oid GetSysCacheOid(int cacheId, AttrNumber oidcol, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:327