Header And Logo

PostgreSQL
| The world's most advanced open source database.

syscache.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * syscache.h
00004  *    System catalog cache definitions.
00005  *
00006  * See also lsyscache.h, which provides convenience routines for
00007  * common cache-lookup operations.
00008  *
00009  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00010  * Portions Copyright (c) 1994, Regents of the University of California
00011  *
00012  * src/include/utils/syscache.h
00013  *
00014  *-------------------------------------------------------------------------
00015  */
00016 #ifndef SYSCACHE_H
00017 #define SYSCACHE_H
00018 
00019 #include "access/attnum.h"
00020 #include "access/htup.h"
00021 /* we purposedly do not include utils/catcache.h here */
00022 
00023 /*
00024  *      SysCache identifiers.
00025  *
00026  *      The order of these identifiers must match the order
00027  *      of the entries in the array cacheinfo[] in syscache.c.
00028  *      Keep them in alphabetical order (renumbering only costs a
00029  *      backend rebuild).
00030  */
00031 
00032 enum SysCacheIdentifier
00033 {
00034     AGGFNOID = 0,
00035     AMNAME,
00036     AMOID,
00037     AMOPOPID,
00038     AMOPSTRATEGY,
00039     AMPROCNUM,
00040     ATTNAME,
00041     ATTNUM,
00042     AUTHMEMMEMROLE,
00043     AUTHMEMROLEMEM,
00044     AUTHNAME,
00045     AUTHOID,
00046     CASTSOURCETARGET,
00047     CLAAMNAMENSP,
00048     CLAOID,
00049     COLLNAMEENCNSP,
00050     COLLOID,
00051     CONDEFAULT,
00052     CONNAMENSP,
00053     CONSTROID,
00054     CONVOID,
00055     DATABASEOID,
00056     DEFACLROLENSPOBJ,
00057     ENUMOID,
00058     ENUMTYPOIDNAME,
00059     EVENTTRIGGERNAME,
00060     EVENTTRIGGEROID,
00061     FOREIGNDATAWRAPPERNAME,
00062     FOREIGNDATAWRAPPEROID,
00063     FOREIGNSERVERNAME,
00064     FOREIGNSERVEROID,
00065     FOREIGNTABLEREL,
00066     INDEXRELID,
00067     LANGNAME,
00068     LANGOID,
00069     NAMESPACENAME,
00070     NAMESPACEOID,
00071     OPERNAMENSP,
00072     OPEROID,
00073     OPFAMILYAMNAMENSP,
00074     OPFAMILYOID,
00075     PROCNAMEARGSNSP,
00076     PROCOID,
00077     RANGETYPE,
00078     RELNAMENSP,
00079     RELOID,
00080     RULERELNAME,
00081     STATRELATTINH,
00082     TABLESPACEOID,
00083     TSCONFIGMAP,
00084     TSCONFIGNAMENSP,
00085     TSCONFIGOID,
00086     TSDICTNAMENSP,
00087     TSDICTOID,
00088     TSPARSERNAMENSP,
00089     TSPARSEROID,
00090     TSTEMPLATENAMENSP,
00091     TSTEMPLATEOID,
00092     TYPENAMENSP,
00093     TYPEOID,
00094     USERMAPPINGOID,
00095     USERMAPPINGUSERSERVER
00096 };
00097 
00098 extern void InitCatalogCache(void);
00099 extern void InitCatalogCachePhase2(void);
00100 
00101 extern HeapTuple SearchSysCache(int cacheId,
00102                Datum key1, Datum key2, Datum key3, Datum key4);
00103 extern void ReleaseSysCache(HeapTuple tuple);
00104 
00105 /* convenience routines */
00106 extern HeapTuple SearchSysCacheCopy(int cacheId,
00107                    Datum key1, Datum key2, Datum key3, Datum key4);
00108 extern bool SearchSysCacheExists(int cacheId,
00109                      Datum key1, Datum key2, Datum key3, Datum key4);
00110 extern Oid GetSysCacheOid(int cacheId,
00111                Datum key1, Datum key2, Datum key3, Datum key4);
00112 
00113 extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
00114 extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
00115 extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
00116 
00117 extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
00118                 AttrNumber attributeNumber, bool *isNull);
00119 
00120 extern uint32 GetSysCacheHashValue(int cacheId,
00121                      Datum key1, Datum key2, Datum key3, Datum key4);
00122 
00123 /* list-search interface.  Users of this must import catcache.h too */
00124 struct catclist;
00125 extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
00126                    Datum key1, Datum key2, Datum key3, Datum key4);
00127 
00128 /*
00129  * The use of the macros below rather than direct calls to the corresponding
00130  * functions is encouraged, as it insulates the caller from changes in the
00131  * maximum number of keys.
00132  */
00133 #define SearchSysCache1(cacheId, key1) \
00134     SearchSysCache(cacheId, key1, 0, 0, 0)
00135 #define SearchSysCache2(cacheId, key1, key2) \
00136     SearchSysCache(cacheId, key1, key2, 0, 0)
00137 #define SearchSysCache3(cacheId, key1, key2, key3) \
00138     SearchSysCache(cacheId, key1, key2, key3, 0)
00139 #define SearchSysCache4(cacheId, key1, key2, key3, key4) \
00140     SearchSysCache(cacheId, key1, key2, key3, key4)
00141 
00142 #define SearchSysCacheCopy1(cacheId, key1) \
00143     SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
00144 #define SearchSysCacheCopy2(cacheId, key1, key2) \
00145     SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
00146 #define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
00147     SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
00148 #define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
00149     SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
00150 
00151 #define SearchSysCacheExists1(cacheId, key1) \
00152     SearchSysCacheExists(cacheId, key1, 0, 0, 0)
00153 #define SearchSysCacheExists2(cacheId, key1, key2) \
00154     SearchSysCacheExists(cacheId, key1, key2, 0, 0)
00155 #define SearchSysCacheExists3(cacheId, key1, key2, key3) \
00156     SearchSysCacheExists(cacheId, key1, key2, key3, 0)
00157 #define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
00158     SearchSysCacheExists(cacheId, key1, key2, key3, key4)
00159 
00160 #define GetSysCacheOid1(cacheId, key1) \
00161     GetSysCacheOid(cacheId, key1, 0, 0, 0)
00162 #define GetSysCacheOid2(cacheId, key1, key2) \
00163     GetSysCacheOid(cacheId, key1, key2, 0, 0)
00164 #define GetSysCacheOid3(cacheId, key1, key2, key3) \
00165     GetSysCacheOid(cacheId, key1, key2, key3, 0)
00166 #define GetSysCacheOid4(cacheId, key1, key2, key3, key4) \
00167     GetSysCacheOid(cacheId, key1, key2, key3, key4)
00168 
00169 #define GetSysCacheHashValue1(cacheId, key1) \
00170     GetSysCacheHashValue(cacheId, key1, 0, 0, 0)
00171 #define GetSysCacheHashValue2(cacheId, key1, key2) \
00172     GetSysCacheHashValue(cacheId, key1, key2, 0, 0)
00173 #define GetSysCacheHashValue3(cacheId, key1, key2, key3) \
00174     GetSysCacheHashValue(cacheId, key1, key2, key3, 0)
00175 #define GetSysCacheHashValue4(cacheId, key1, key2, key3, key4) \
00176     GetSysCacheHashValue(cacheId, key1, key2, key3, key4)
00177 
00178 #define SearchSysCacheList1(cacheId, key1) \
00179     SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
00180 #define SearchSysCacheList2(cacheId, key1, key2) \
00181     SearchSysCacheList(cacheId, 2, key1, key2, 0, 0)
00182 #define SearchSysCacheList3(cacheId, key1, key2, key3) \
00183     SearchSysCacheList(cacheId, 3, key1, key2, key3, 0)
00184 #define SearchSysCacheList4(cacheId, key1, key2, key3, key4) \
00185     SearchSysCacheList(cacheId, 4, key1, key2, key3, key4)
00186 
00187 #define ReleaseSysCacheList(x)  ReleaseCatCacheList(x)
00188 
00189 #endif   /* SYSCACHE_H */