syscache.h 6.4 KB

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