PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
relcache.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * relcache.h
4  * Relation descriptor cache definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, 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 
17 #include "access/tupdesc.h"
18 #include "nodes/bitmapset.h"
19 
20 
21 typedef struct RelationData *Relation;
22 
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 /*
32  * Routines to open (lookup) and close a relcache entry
33  */
34 extern Relation RelationIdGetRelation(Oid relationId);
35 extern void RelationClose(Relation relation);
36 
37 /*
38  * Routines to compute/retrieve additional cached information
39  */
40 extern List *RelationGetFKeyList(Relation relation);
41 extern List *RelationGetIndexList(Relation relation);
42 extern List *RelationGetStatExtList(Relation relation);
43 extern Oid RelationGetOidIndex(Relation relation);
44 extern Oid RelationGetPrimaryKeyIndex(Relation relation);
45 extern Oid RelationGetReplicaIndex(Relation relation);
46 extern List *RelationGetIndexExpressions(Relation relation);
47 extern List *RelationGetIndexPredicate(Relation relation);
48 
49 typedef enum IndexAttrBitmapKind
50 {
56 
57 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
58  IndexAttrBitmapKind keyAttrs);
59 
60 extern void RelationGetExclusionInfo(Relation indexRelation,
61  Oid **operators,
62  Oid **procs,
63  uint16 **strategies);
64 
65 extern void RelationSetIndexList(Relation relation,
66  List *indexIds, Oid oidIndex);
67 
68 extern void RelationInitIndexAccessInfo(Relation relation);
69 
70 /* caller must include pg_publication.h */
71 struct PublicationActions;
72 extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
73 
74 /*
75  * Routines to support ereport() reports of relation-related errors
76  */
77 extern int errtable(Relation rel);
78 extern int errtablecol(Relation rel, int attnum);
79 extern int errtablecolname(Relation rel, const char *colname);
80 extern int errtableconstraint(Relation rel, const char *conname);
81 
82 /*
83  * Routines for backend startup
84  */
85 extern void RelationCacheInitialize(void);
86 extern void RelationCacheInitializePhase2(void);
87 extern void RelationCacheInitializePhase3(void);
88 
89 /*
90  * Routine to create a relcache entry for an about-to-be-created relation
91  */
92 extern Relation RelationBuildLocalRelation(const char *relname,
93  Oid relnamespace,
94  TupleDesc tupDesc,
95  Oid relid,
96  Oid relfilenode,
97  Oid reltablespace,
98  bool shared_relation,
99  bool mapped_relation,
100  char relpersistence,
101  char relkind);
102 
103 /*
104  * Routine to manage assignment of new relfilenode to a relation
105  */
106 extern void RelationSetNewRelfilenode(Relation relation, char persistence,
107  TransactionId freezeXid, MultiXactId minmulti);
108 
109 /*
110  * Routines for flushing/rebuilding relcache entries in various scenarios
111  */
112 extern void RelationForgetRelation(Oid rid);
113 
114 extern void RelationCacheInvalidateEntry(Oid relationId);
115 
116 extern void RelationCacheInvalidate(void);
117 
118 extern void RelationCloseSmgrByOid(Oid relationId);
119 
120 extern void AtEOXact_RelationCache(bool isCommit);
121 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
122  SubTransactionId parentSubid);
123 
124 /*
125  * Routines to help manage rebuilding of relcache init files
126  */
127 extern bool RelationIdIsInInitFile(Oid relationId);
128 extern void RelationCacheInitFilePreInvalidate(void);
129 extern void RelationCacheInitFilePostInvalidate(void);
130 extern void RelationCacheInitFileRemove(void);
131 
132 /* should be used only by relcache.c and catcache.c */
133 extern bool criticalRelcachesBuilt;
134 
135 /* should be used only by relcache.c and postinit.c */
136 extern bool criticalSharedRelcachesBuilt;
137 
138 #endif /* RELCACHE_H */
void RelationCacheInitFileRemove(void)
Definition: relcache.c:6090
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3073
void RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex)
Definition: relcache.c:4602
int errtable(Relation rel)
Definition: relcache.c:5249
uint32 TransactionId
Definition: c.h:397
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5303
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3571
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5290
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4351
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2686
uint32 SubTransactionId
Definition: c.h:401
bool criticalRelcachesBuilt
Definition: relcache.c:129
unsigned int Oid
Definition: postgres_ext.h:31
IndexAttrBitmapKind
Definition: relcache.h:49
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5266
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:2922
struct RelationData * Relation
Definition: relcache.h:21
unsigned short uint16
Definition: c.h:267
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:5966
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind keyAttrs)
Definition: relcache.c:4853
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6049
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4682
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3630
Relation * RelationPtr
Definition: relcache.h:29
void RelationSetNewRelfilenode(Relation relation, char persistence, TransactionId freezeXid, MultiXactId minmulti)
Definition: relcache.c:3422
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4707
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:2865
void RelationClose(Relation relation)
Definition: relcache.c:2162
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2718
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6075
bool criticalSharedRelcachesBuilt
Definition: relcache.c:135
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:5060
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4188
TransactionId MultiXactId
Definition: c.h:407
void RelationCacheInitialize(void)
Definition: relcache.c:3534
struct PublicationActions * GetRelationPublicationActions(Relation relation)
Definition: relcache.c:5178
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4661
void RelationCacheInvalidate(void)
Definition: relcache.c:2762
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:2073
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4491
Relation RelationBuildLocalRelation(const char *relname, Oid relnamespace, TupleDesc tupDesc, Oid relid, Oid relfilenode, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence, char relkind)
Definition: relcache.c:3185
Definition: pg_list.h:45
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4770
Oid RelationGetOidIndex(Relation relation)
Definition: relcache.c:4633
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1511