codekingpro/portable-devtools
116k
1/*-------------------------------------------------------------------------2 *3 * syscache.h4 * System catalog cache definitions.5 *6 * See also lsyscache.h, which provides convenience routines for7 * common cache-lookup operations.8 *9 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group10 * Portions Copyright (c) 1994, Regents of the University of California11 *12 * src/include/utils/syscache.h13 *14 *-------------------------------------------------------------------------15 */16#ifndef SYSCACHE_H17#define SYSCACHE_H18 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 order27 * of the entries in the array cacheinfo[] in syscache.c.28 * Keep them in alphabetical order (renumbering only costs a29 * backend rebuild).30 */31 32enum SysCacheIdentifier33{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 PARAMETERACLNAME,76 PARAMETERACLOID,77 PARTRELID,78 PROCNAMEARGSNSP,79 PROCOID,80 PUBLICATIONNAME,81 PUBLICATIONNAMESPACE,82 PUBLICATIONNAMESPACEMAP,83 PUBLICATIONOID,84 PUBLICATIONREL,85 PUBLICATIONRELMAP,86 RANGEMULTIRANGE,87 RANGETYPE,88 RELNAMENSP,89 RELOID,90 REPLORIGIDENT,91 REPLORIGNAME,92 RULERELNAME,93 SEQRELID,94 STATEXTDATASTXOID,95 STATEXTNAMENSP,96 STATEXTOID,97 STATRELATTINH,98 SUBSCRIPTIONNAME,99 SUBSCRIPTIONOID,100 SUBSCRIPTIONRELMAP,101 TABLESPACEOID,102 TRFOID,103 TRFTYPELANG,104 TSCONFIGMAP,105 TSCONFIGNAMENSP,106 TSCONFIGOID,107 TSDICTNAMENSP,108 TSDICTOID,109 TSPARSERNAMENSP,110 TSPARSEROID,111 TSTEMPLATENAMENSP,112 TSTEMPLATEOID,113 TYPENAMENSP,114 TYPEOID,115 USERMAPPINGOID,116 USERMAPPINGUSERSERVER117 118#define SysCacheSize (USERMAPPINGUSERSERVER + 1)119};120 121extern void InitCatalogCache(void);122extern void InitCatalogCachePhase2(void);123 124extern 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, and129 * insulates the caller from changes in the maximum number of keys.130 */131extern HeapTuple SearchSysCache1(int cacheId,132 Datum key1);133extern HeapTuple SearchSysCache2(int cacheId,134 Datum key1, Datum key2);135extern HeapTuple SearchSysCache3(int cacheId,136 Datum key1, Datum key2, Datum key3);137extern HeapTuple SearchSysCache4(int cacheId,138 Datum key1, Datum key2, Datum key3, Datum key4);139 140extern void ReleaseSysCache(HeapTuple tuple);141 142/* convenience routines */143extern HeapTuple SearchSysCacheCopy(int cacheId,144 Datum key1, Datum key2, Datum key3, Datum key4);145extern bool SearchSysCacheExists(int cacheId,146 Datum key1, Datum key2, Datum key3, Datum key4);147extern Oid GetSysCacheOid(int cacheId, AttrNumber oidcol,148 Datum key1, Datum key2, Datum key3, Datum key4);149 150extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);151extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);152extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);153 154extern HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum);155extern HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum);156 157extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,158 AttrNumber attributeNumber, bool *isNull);159 160extern Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup,161 AttrNumber attributeNumber);162 163extern 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 */167struct catclist;168extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,169 Datum key1, Datum key2, Datum key3);170 171extern void SysCacheInvalidate(int cacheId, uint32 hashValue);172 173extern bool RelationInvalidatesSnapshotsOnly(Oid relid);174extern bool RelationHasSysCache(Oid relid);175extern bool RelationSupportsSysCache(Oid relid);176 177/*178 * The use of the macros below rather than direct calls to the corresponding179 * functions is encouraged, as it insulates the caller from changes in the180 * 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 */228 