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-2016, 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 PROCNAMEARGSNSP, 76 PROCOID, 77 RANGETYPE, 78 RELNAMENSP, 79 RELOID, 80 REPLORIGIDENT, 81 REPLORIGNAME, 82 RULERELNAME, 83 STATRELATTINH, 84 TABLESPACEOID, 85 TRFOID, 86 TRFTYPELANG, 87 TSCONFIGMAP, 88 TSCONFIGNAMENSP, 89 TSCONFIGOID, 90 TSDICTNAMENSP, 91 TSDICTOID, 92 TSPARSERNAMENSP, 93 TSPARSEROID, 94 TSTEMPLATENAMENSP, 95 TSTEMPLATEOID, 96 TYPENAMENSP, 97 TYPEOID, 98 USERMAPPINGOID, 99 USERMAPPINGUSERSERVER 100 101 #define SysCacheSize (USERMAPPINGUSERSERVER + 1) 102 }; 103 104 extern void InitCatalogCache(void); 105 extern void InitCatalogCachePhase2(void); 106 107 extern HeapTuple SearchSysCache(int cacheId, 108 Datum key1, Datum key2, Datum key3, Datum key4); 109 extern void ReleaseSysCache(HeapTuple tuple); 110 111 /* convenience routines */ 112 extern HeapTuple SearchSysCacheCopy(int cacheId, 113 Datum key1, Datum key2, Datum key3, Datum key4); 114 extern bool SearchSysCacheExists(int cacheId, 115 Datum key1, Datum key2, Datum key3, Datum key4); 116 extern Oid GetSysCacheOid(int cacheId, 117 Datum key1, Datum key2, Datum key3, Datum key4); 118 119 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname); 120 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname); 121 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname); 122 123 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup, 124 AttrNumber attributeNumber, bool *isNull); 125 126 extern uint32 GetSysCacheHashValue(int cacheId, 127 Datum key1, Datum key2, Datum key3, Datum key4); 128 129 /* list-search interface. Users of this must import catcache.h too */ 130 struct catclist; 131 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys, 132 Datum key1, Datum key2, Datum key3, Datum key4); 133 134 extern void SysCacheInvalidate(int cacheId, uint32 hashValue); 135 136 extern bool RelationInvalidatesSnapshotsOnly(Oid relid); 137 extern bool RelationHasSysCache(Oid relid); 138 extern bool RelationSupportsSysCache(Oid relid); 139 140 /* 141 * The use of the macros below rather than direct calls to the corresponding 142 * functions is encouraged, as it insulates the caller from changes in the 143 * maximum number of keys. 144 */ 145 #define SearchSysCache1(cacheId, key1) \ 146 SearchSysCache(cacheId, key1, 0, 0, 0) 147 #define SearchSysCache2(cacheId, key1, key2) \ 148 SearchSysCache(cacheId, key1, key2, 0, 0) 149 #define SearchSysCache3(cacheId, key1, key2, key3) \ 150 SearchSysCache(cacheId, key1, key2, key3, 0) 151 #define SearchSysCache4(cacheId, key1, key2, key3, key4) \ 152 SearchSysCache(cacheId, key1, key2, key3, key4) 153 154 #define SearchSysCacheCopy1(cacheId, key1) \ 155 SearchSysCacheCopy(cacheId, key1, 0, 0, 0) 156 #define SearchSysCacheCopy2(cacheId, key1, key2) \ 157 SearchSysCacheCopy(cacheId, key1, key2, 0, 0) 158 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \ 159 SearchSysCacheCopy(cacheId, key1, key2, key3, 0) 160 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \ 161 SearchSysCacheCopy(cacheId, key1, key2, key3, key4) 162 163 #define SearchSysCacheExists1(cacheId, key1) \ 164 SearchSysCacheExists(cacheId, key1, 0, 0, 0) 165 #define SearchSysCacheExists2(cacheId, key1, key2) \ 166 SearchSysCacheExists(cacheId, key1, key2, 0, 0) 167 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \ 168 SearchSysCacheExists(cacheId, key1, key2, key3, 0) 169 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \ 170 SearchSysCacheExists(cacheId, key1, key2, key3, key4) 171 172 #define GetSysCacheOid1(cacheId, key1) \ 173 GetSysCacheOid(cacheId, key1, 0, 0, 0) 174 #define GetSysCacheOid2(cacheId, key1, key2) \ 175 GetSysCacheOid(cacheId, key1, key2, 0, 0) 176 #define GetSysCacheOid3(cacheId, key1, key2, key3) \ 177 GetSysCacheOid(cacheId, key1, key2, key3, 0) 178 #define GetSysCacheOid4(cacheId, key1, key2, key3, key4) \ 179 GetSysCacheOid(cacheId, key1, key2, key3, key4) 180 181 #define GetSysCacheHashValue1(cacheId, key1) \ 182 GetSysCacheHashValue(cacheId, key1, 0, 0, 0) 183 #define GetSysCacheHashValue2(cacheId, key1, key2) \ 184 GetSysCacheHashValue(cacheId, key1, key2, 0, 0) 185 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \ 186 GetSysCacheHashValue(cacheId, key1, key2, key3, 0) 187 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \ 188 GetSysCacheHashValue(cacheId, key1, key2, key3, key4) 189 190 #define SearchSysCacheList1(cacheId, key1) \ 191 SearchSysCacheList(cacheId, 1, key1, 0, 0, 0) 192 #define SearchSysCacheList2(cacheId, key1, key2) \ 193 SearchSysCacheList(cacheId, 2, key1, key2, 0, 0) 194 #define SearchSysCacheList3(cacheId, key1, key2, key3) \ 195 SearchSysCacheList(cacheId, 3, key1, key2, key3, 0) 196 #define SearchSysCacheList4(cacheId, key1, key2, key3, key4) \ 197 SearchSysCacheList(cacheId, 4, key1, key2, key3, key4) 198 199 #define ReleaseSysCacheList(x) ReleaseCatCacheList(x) 200 201 #endif /* SYSCACHE_H */ 202