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