1 /*-------------------------------------------------------------------------
4 * Relation descriptor cache definitions.
7 * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/utils/relcache.h
12 *-------------------------------------------------------------------------
17 #include "access/tupdesc.h"
18 #include "nodes/bitmapset.h"
21 typedef struct RelationData *Relation;
24 * RelationPtr is used in the executor to support index scans
25 * where we have to keep track of several index relations in an
29 typedef Relation *RelationPtr;
32 * Routines to open (lookup) and close a relcache entry
34 extern Relation RelationIdGetRelation(Oid relationId);
35 extern void RelationClose(Relation relation);
38 * Routines to compute/retrieve additional cached information
40 extern List *RelationGetIndexList(Relation relation);
41 extern Oid RelationGetOidIndex(Relation relation);
42 extern Oid RelationGetReplicaIndex(Relation relation);
43 extern List *RelationGetIndexExpressions(Relation relation);
44 extern List *RelationGetIndexPredicate(Relation relation);
46 typedef enum IndexAttrBitmapKind
48 INDEX_ATTR_BITMAP_ALL,
49 INDEX_ATTR_BITMAP_KEY,
50 INDEX_ATTR_BITMAP_IDENTITY_KEY
51 } IndexAttrBitmapKind;
53 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
54 IndexAttrBitmapKind keyAttrs);
56 extern void RelationGetExclusionInfo(Relation indexRelation,
61 extern void RelationSetIndexList(Relation relation,
62 List *indexIds, Oid oidIndex);
64 extern void RelationInitIndexAccessInfo(Relation relation);
67 * Routines to support ereport() reports of relation-related errors
69 extern int errtable(Relation rel);
70 extern int errtablecol(Relation rel, int attnum);
71 extern int errtablecolname(Relation rel, const char *colname);
72 extern int errtableconstraint(Relation rel, const char *conname);
75 * Routines for backend startup
77 extern void RelationCacheInitialize(void);
78 extern void RelationCacheInitializePhase2(void);
79 extern void RelationCacheInitializePhase3(void);
82 * Routine to create a relcache entry for an about-to-be-created relation
84 extern Relation RelationBuildLocalRelation(const char *relname,
96 * Routine to manage assignment of new relfilenode to a relation
98 extern void RelationSetNewRelfilenode(Relation relation,
99 TransactionId freezeXid, MultiXactId minmulti);
102 * Routines for flushing/rebuilding relcache entries in various scenarios
104 extern void RelationForgetRelation(Oid rid);
106 extern void RelationCacheInvalidateEntry(Oid relationId);
108 extern void RelationCacheInvalidate(void);
110 extern void RelationCloseSmgrByOid(Oid relationId);
112 extern void AtEOXact_RelationCache(bool isCommit);
113 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
114 SubTransactionId parentSubid);
117 * Routines to help manage rebuilding of relcache init files
119 extern bool RelationIdIsInInitFile(Oid relationId);
120 extern void RelationCacheInitFilePreInvalidate(void);
121 extern void RelationCacheInitFilePostInvalidate(void);
122 extern void RelationCacheInitFileRemove(void);
124 /* should be used only by relcache.c and catcache.c */
125 extern bool criticalRelcachesBuilt;
127 /* should be used only by relcache.c and postinit.c */
128 extern bool criticalSharedRelcachesBuilt;
130 #endif /* RELCACHE_H */