2
0

relcache.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*-------------------------------------------------------------------------
  2. *
  3. * relcache.h
  4. * Relation descriptor cache definitions.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/utils/relcache.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef RELCACHE_H
  15. #define RELCACHE_H
  16. #include "access/tupdesc.h"
  17. #include "nodes/bitmapset.h"
  18. /*
  19. * Name of relcache init file(s), used to speed up backend startup
  20. */
  21. #define RELCACHE_INIT_FILENAME "pg_internal.init"
  22. typedef struct RelationData *Relation;
  23. /* ----------------
  24. * RelationPtr is used in the executor to support index scans
  25. * where we have to keep track of several index relations in an
  26. * array. -cim 9/10/89
  27. * ----------------
  28. */
  29. typedef Relation *RelationPtr;
  30. /*
  31. * Routines to open (lookup) and close a relcache entry
  32. */
  33. extern Relation RelationIdGetRelation(Oid relationId);
  34. extern void RelationClose(Relation relation);
  35. /*
  36. * Routines to compute/retrieve additional cached information
  37. */
  38. extern List *RelationGetFKeyList(Relation relation);
  39. extern List *RelationGetIndexList(Relation relation);
  40. extern List *RelationGetStatExtList(Relation relation);
  41. extern Oid RelationGetPrimaryKeyIndex(Relation relation);
  42. extern Oid RelationGetReplicaIndex(Relation relation);
  43. extern List *RelationGetIndexExpressions(Relation relation);
  44. extern List *RelationGetDummyIndexExpressions(Relation relation);
  45. extern List *RelationGetIndexPredicate(Relation relation);
  46. extern Datum *RelationGetIndexRawAttOptions(Relation relation);
  47. extern bytea **RelationGetIndexAttOptions(Relation relation, bool copy);
  48. typedef enum IndexAttrBitmapKind
  49. {
  50. INDEX_ATTR_BITMAP_ALL,
  51. INDEX_ATTR_BITMAP_KEY,
  52. INDEX_ATTR_BITMAP_PRIMARY_KEY,
  53. INDEX_ATTR_BITMAP_IDENTITY_KEY
  54. } IndexAttrBitmapKind;
  55. extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
  56. IndexAttrBitmapKind attrKind);
  57. extern Bitmapset *RelationGetIdentityKeyBitmap(Relation relation);
  58. extern void RelationGetExclusionInfo(Relation indexRelation,
  59. Oid **operators,
  60. Oid **procs,
  61. uint16 **strategies);
  62. extern void RelationInitIndexAccessInfo(Relation relation);
  63. /* caller must include pg_publication.h */
  64. struct PublicationDesc;
  65. extern void RelationBuildPublicationDesc(Relation relation,
  66. struct PublicationDesc *pubdesc);
  67. extern void RelationInitTableAccessMethod(Relation relation);
  68. /*
  69. * Routines to support ereport() reports of relation-related errors
  70. */
  71. extern int errtable(Relation rel);
  72. extern int errtablecol(Relation rel, int attnum);
  73. extern int errtablecolname(Relation rel, const char *colname);
  74. extern int errtableconstraint(Relation rel, const char *conname);
  75. /*
  76. * Routines for backend startup
  77. */
  78. extern void RelationCacheInitialize(void);
  79. extern void RelationCacheInitializePhase2(void);
  80. extern void RelationCacheInitializePhase3(void);
  81. /*
  82. * Routine to create a relcache entry for an about-to-be-created relation
  83. */
  84. extern Relation RelationBuildLocalRelation(const char *relname,
  85. Oid relnamespace,
  86. TupleDesc tupDesc,
  87. Oid relid,
  88. Oid accessmtd,
  89. Oid relfilenode,
  90. Oid reltablespace,
  91. bool shared_relation,
  92. bool mapped_relation,
  93. char relpersistence,
  94. char relkind);
  95. /*
  96. * Routines to manage assignment of new relfilenode to a relation
  97. */
  98. extern void RelationSetNewRelfilenode(Relation relation, char persistence);
  99. extern void RelationAssumeNewRelfilenode(Relation relation);
  100. /*
  101. * Routines for flushing/rebuilding relcache entries in various scenarios
  102. */
  103. extern void RelationForgetRelation(Oid rid);
  104. extern void RelationCacheInvalidateEntry(Oid relationId);
  105. extern void RelationCacheInvalidate(bool debug_discard);
  106. extern void RelationCloseSmgrByOid(Oid relationId);
  107. #ifdef USE_ASSERT_CHECKING
  108. extern void AssertPendingSyncs_RelationCache(void);
  109. #else
  110. #define AssertPendingSyncs_RelationCache() do {} while (0)
  111. #endif
  112. extern void AtEOXact_RelationCache(bool isCommit);
  113. extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
  114. SubTransactionId parentSubid);
  115. /*
  116. * Routines to help manage rebuilding of relcache init files
  117. */
  118. extern bool RelationIdIsInInitFile(Oid relationId);
  119. extern void RelationCacheInitFilePreInvalidate(void);
  120. extern void RelationCacheInitFilePostInvalidate(void);
  121. extern void RelationCacheInitFileRemove(void);
  122. /* should be used only by relcache.c and catcache.c */
  123. extern PGDLLIMPORT bool criticalRelcachesBuilt;
  124. /* should be used only by relcache.c and postinit.c */
  125. extern PGDLLIMPORT bool criticalSharedRelcachesBuilt;
  126. #endif /* RELCACHE_H */