syscache.h 5.9 KB

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