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-2025, 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" /* IWYU pragma: export */
24
25extern void InitCatalogCache(void);
26extern void InitCatalogCachePhase2(void);
27
28extern 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 */
35extern HeapTuple SearchSysCache1(int cacheId,
36 Datum key1);
37extern HeapTuple SearchSysCache2(int cacheId,
38 Datum key1, Datum key2);
39extern HeapTuple SearchSysCache3(int cacheId,
40 Datum key1, Datum key2, Datum key3);
41extern HeapTuple SearchSysCache4(int cacheId,
42 Datum key1, Datum key2, Datum key3, Datum key4);
43
44extern void ReleaseSysCache(HeapTuple tuple);
45
46extern HeapTuple SearchSysCacheLocked1(int cacheId,
47 Datum key1);
48
49/* convenience routines */
50extern HeapTuple SearchSysCacheCopy(int cacheId,
51 Datum key1, Datum key2, Datum key3, Datum key4);
52extern HeapTuple SearchSysCacheLockedCopy1(int cacheId,
53 Datum key1);
54extern bool SearchSysCacheExists(int cacheId,
55 Datum key1, Datum key2, Datum key3, Datum key4);
56extern Oid GetSysCacheOid(int cacheId, AttrNumber oidcol,
57 Datum key1, Datum key2, Datum key3, Datum key4);
58
59extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
60extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
61extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
62
65
66extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
67 AttrNumber attributeNumber, bool *isNull);
68
69extern Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup,
70 AttrNumber attributeNumber);
71
72extern uint32 GetSysCacheHashValue(int cacheId,
73 Datum key1, Datum key2, Datum key3, Datum key4);
74
75/* list-search interface. Users of this must import catcache.h too */
76struct catclist;
77extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
78 Datum key1, Datum key2, Datum key3);
79
80extern void SysCacheInvalidate(int cacheId, uint32 hashValue);
81
82extern bool RelationInvalidatesSnapshotsOnly(Oid relid);
83extern bool RelationHasSysCache(Oid relid);
84extern bool RelationSupportsSysCache(Oid relid);
85
86/*
87 * The use of the macros below rather than direct calls to the corresponding
88 * functions is encouraged, as it insulates the caller from changes in the
89 * maximum number of keys.
90 */
91#define SearchSysCacheCopy1(cacheId, key1) \
92 SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
93#define SearchSysCacheCopy2(cacheId, key1, key2) \
94 SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
95#define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
96 SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
97#define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
98 SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
99
100#define SearchSysCacheExists1(cacheId, key1) \
101 SearchSysCacheExists(cacheId, key1, 0, 0, 0)
102#define SearchSysCacheExists2(cacheId, key1, key2) \
103 SearchSysCacheExists(cacheId, key1, key2, 0, 0)
104#define SearchSysCacheExists3(cacheId, key1, key2, key3) \
105 SearchSysCacheExists(cacheId, key1, key2, key3, 0)
106#define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
107 SearchSysCacheExists(cacheId, key1, key2, key3, key4)
108
109#define GetSysCacheOid1(cacheId, oidcol, key1) \
110 GetSysCacheOid(cacheId, oidcol, key1, 0, 0, 0)
111#define GetSysCacheOid2(cacheId, oidcol, key1, key2) \
112 GetSysCacheOid(cacheId, oidcol, key1, key2, 0, 0)
113#define GetSysCacheOid3(cacheId, oidcol, key1, key2, key3) \
114 GetSysCacheOid(cacheId, oidcol, key1, key2, key3, 0)
115#define GetSysCacheOid4(cacheId, oidcol, key1, key2, key3, key4) \
116 GetSysCacheOid(cacheId, oidcol, key1, key2, key3, key4)
117
118#define GetSysCacheHashValue1(cacheId, key1) \
119 GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
120#define GetSysCacheHashValue2(cacheId, key1, key2) \
121 GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
122#define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
123 GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
124#define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
125 GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
126
127#define SearchSysCacheList1(cacheId, key1) \
128 SearchSysCacheList(cacheId, 1, key1, 0, 0)
129#define SearchSysCacheList2(cacheId, key1, key2) \
130 SearchSysCacheList(cacheId, 2, key1, key2, 0)
131#define SearchSysCacheList3(cacheId, key1, key2, key3) \
132 SearchSysCacheList(cacheId, 3, key1, key2, key3)
133
134#define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
135
136#endif /* SYSCACHE_H */
int16 AttrNumber
Definition: attnum.h:21
int16_t int16
Definition: c.h:483
uint32_t uint32
Definition: c.h:488
NameData attname
Definition: pg_attribute.h:41
int16 attnum
Definition: pg_attribute.h:74
uintptr_t Datum
Definition: postgres.h:69
unsigned int Oid
Definition: postgres_ext.h:32
short nkeys
Definition: catcache.h:177
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:503
void SysCacheInvalidate(int cacheId, uint32 hashValue)
Definition: syscache.c:698
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:678
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:745
HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
Definition: syscache.c:566
void InitCatalogCache(void)
Definition: syscache.c:110
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:269
HeapTuple SearchSysCacheLocked1(int cacheId, Datum key1)
Definition: syscache.c:287
HeapTuple SearchSysCacheLockedCopy1(int cacheId, Datum key1)
Definition: syscache.c:404
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:208
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:221
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:661
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:243
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:543
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:770
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:600
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:522
void InitCatalogCachePhase2(void)
Definition: syscache.c:180
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:232
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:480
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:425
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:379
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:722
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:254
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition: syscache.c:631
Oid GetSysCacheOid(int cacheId, AttrNumber oidcol, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:448