relcache.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*-------------------------------------------------------------------------
  2. *
  3. * relcache.h
  4. * Relation descriptor cache definitions.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, 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. typedef struct RelationData *Relation;
  19. /* ----------------
  20. * RelationPtr is used in the executor to support index scans
  21. * where we have to keep track of several index relations in an
  22. * array. -cim 9/10/89
  23. * ----------------
  24. */
  25. typedef Relation *RelationPtr;
  26. /*
  27. * Routines to open (lookup) and close a relcache entry
  28. */
  29. extern Relation RelationIdGetRelation(Oid relationId);
  30. extern void RelationClose(Relation relation);
  31. /*
  32. * Routines to compute/retrieve additional cached information
  33. */
  34. extern List *RelationGetFKeyList(Relation relation);
  35. extern List *RelationGetIndexList(Relation relation);
  36. extern Oid RelationGetOidIndex(Relation relation);
  37. extern Oid RelationGetReplicaIndex(Relation relation);
  38. extern List *RelationGetIndexExpressions(Relation relation);
  39. extern List *RelationGetIndexPredicate(Relation relation);
  40. typedef enum IndexAttrBitmapKind
  41. {
  42. INDEX_ATTR_BITMAP_ALL,
  43. INDEX_ATTR_BITMAP_KEY,
  44. INDEX_ATTR_BITMAP_IDENTITY_KEY
  45. } IndexAttrBitmapKind;
  46. extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
  47. IndexAttrBitmapKind keyAttrs);
  48. extern void RelationGetExclusionInfo(Relation indexRelation,
  49. Oid **operators,
  50. Oid **procs,
  51. uint16 **strategies);
  52. extern void RelationSetIndexList(Relation relation,
  53. List *indexIds, Oid oidIndex);
  54. extern void RelationInitIndexAccessInfo(Relation relation);
  55. /*
  56. * Routines to support ereport() reports of relation-related errors
  57. */
  58. extern int errtable(Relation rel);
  59. extern int errtablecol(Relation rel, int attnum);
  60. extern int errtablecolname(Relation rel, const char *colname);
  61. extern int errtableconstraint(Relation rel, const char *conname);
  62. /*
  63. * Routines for backend startup
  64. */
  65. extern void RelationCacheInitialize(void);
  66. extern void RelationCacheInitializePhase2(void);
  67. extern void RelationCacheInitializePhase3(void);
  68. /*
  69. * Routine to create a relcache entry for an about-to-be-created relation
  70. */
  71. extern Relation RelationBuildLocalRelation(const char *relname,
  72. Oid relnamespace,
  73. TupleDesc tupDesc,
  74. Oid relid,
  75. Oid relfilenode,
  76. Oid reltablespace,
  77. bool shared_relation,
  78. bool mapped_relation,
  79. char relpersistence,
  80. char relkind);
  81. /*
  82. * Routine to manage assignment of new relfilenode to a relation
  83. */
  84. extern void RelationSetNewRelfilenode(Relation relation, char persistence,
  85. TransactionId freezeXid, MultiXactId minmulti);
  86. /*
  87. * Routines for flushing/rebuilding relcache entries in various scenarios
  88. */
  89. extern void RelationForgetRelation(Oid rid);
  90. extern void RelationCacheInvalidateEntry(Oid relationId);
  91. extern void RelationCacheInvalidate(void);
  92. extern void RelationCloseSmgrByOid(Oid relationId);
  93. extern void AtEOXact_RelationCache(bool isCommit);
  94. extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
  95. SubTransactionId parentSubid);
  96. /*
  97. * Routines to help manage rebuilding of relcache init files
  98. */
  99. extern bool RelationIdIsInInitFile(Oid relationId);
  100. extern void RelationCacheInitFilePreInvalidate(void);
  101. extern void RelationCacheInitFilePostInvalidate(void);
  102. extern void RelationCacheInitFileRemove(void);
  103. /* should be used only by relcache.c and catcache.c */
  104. extern bool criticalRelcachesBuilt;
  105. /* should be used only by relcache.c and postinit.c */
  106. extern bool criticalSharedRelcachesBuilt;
  107. #endif /* RELCACHE_H */