PostgreSQL Source Code  git master
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 /*
22  * Name of relcache init file(s), used to speed up backend startup
23  */
24 #define RELCACHE_INIT_FILENAME "pg_internal.init"
25 
26 typedef struct RelationData *Relation;
27 
28 /* ----------------
29  * RelationPtr is used in the executor to support index scans
30  * where we have to keep track of several index relations in an
31  * array. -cim 9/10/89
32  * ----------------
33  */
34 typedef Relation *RelationPtr;
35 
36 /*
37  * Routines to open (lookup) and close a relcache entry
38  */
39 extern Relation RelationIdGetRelation(Oid relationId);
40 extern void RelationClose(Relation relation);
41 
42 /*
43  * Routines to compute/retrieve additional cached information
44  */
45 extern List *RelationGetFKeyList(Relation relation);
46 extern List *RelationGetIndexList(Relation relation);
47 extern List *RelationGetStatExtList(Relation relation);
48 extern Oid RelationGetOidIndex(Relation relation);
49 extern Oid RelationGetPrimaryKeyIndex(Relation relation);
50 extern Oid RelationGetReplicaIndex(Relation relation);
51 extern List *RelationGetIndexExpressions(Relation relation);
52 extern List *RelationGetIndexPredicate(Relation relation);
53 
54 typedef enum IndexAttrBitmapKind
55 {
61 
62 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
63  IndexAttrBitmapKind keyAttrs);
64 
65 extern void RelationGetExclusionInfo(Relation indexRelation,
66  Oid **operators,
67  Oid **procs,
68  uint16 **strategies);
69 
70 extern void RelationSetIndexList(Relation relation,
71  List *indexIds, Oid oidIndex);
72 
73 extern void RelationInitIndexAccessInfo(Relation relation);
74 
75 /* caller must include pg_publication.h */
76 struct PublicationActions;
77 extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
78 
79 /*
80  * Routines to support ereport() reports of relation-related errors
81  */
82 extern int errtable(Relation rel);
83 extern int errtablecol(Relation rel, int attnum);
84 extern int errtablecolname(Relation rel, const char *colname);
85 extern int errtableconstraint(Relation rel, const char *conname);
86 
87 /*
88  * Routines for backend startup
89  */
90 extern void RelationCacheInitialize(void);
91 extern void RelationCacheInitializePhase2(void);
92 extern void RelationCacheInitializePhase3(void);
93 
94 /*
95  * Routine to create a relcache entry for an about-to-be-created relation
96  */
97 extern Relation RelationBuildLocalRelation(const char *relname,
98  Oid relnamespace,
99  TupleDesc tupDesc,
100  Oid relid,
101  Oid relfilenode,
102  Oid reltablespace,
103  bool shared_relation,
104  bool mapped_relation,
105  char relpersistence,
106  char relkind);
107 
108 /*
109  * Routine to manage assignment of new relfilenode to a relation
110  */
111 extern void RelationSetNewRelfilenode(Relation relation, char persistence,
112  TransactionId freezeXid, MultiXactId minmulti);
113 
114 /*
115  * Routines for flushing/rebuilding relcache entries in various scenarios
116  */
117 extern void RelationForgetRelation(Oid rid);
118 
119 extern void RelationCacheInvalidateEntry(Oid relationId);
120 
121 extern void RelationCacheInvalidate(void);
122 
123 extern void RelationCloseSmgrByOid(Oid relationId);
124 
125 extern void AtEOXact_RelationCache(bool isCommit);
126 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
127  SubTransactionId parentSubid);
128 
129 /*
130  * Routines to help manage rebuilding of relcache init files
131  */
132 extern bool RelationIdIsInInitFile(Oid relationId);
133 extern void RelationCacheInitFilePreInvalidate(void);
134 extern void RelationCacheInitFilePostInvalidate(void);
135 extern void RelationCacheInitFileRemove(void);
136 
137 /* should be used only by relcache.c and catcache.c */
138 extern bool criticalRelcachesBuilt;
139 
140 /* should be used only by relcache.c and postinit.c */
141 extern bool criticalSharedRelcachesBuilt;
142 
143 #endif /* RELCACHE_H */
void RelationCacheInitFileRemove(void)
Definition: relcache.c:6107
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3081
void RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex)
Definition: relcache.c:4614
int errtable(Relation rel)
Definition: relcache.c:5261
uint32 TransactionId
Definition: c.h:455
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5315
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3582
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5302
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4363
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2694
uint32 SubTransactionId
Definition: c.h:459
bool criticalRelcachesBuilt
Definition: relcache.c:125
unsigned int Oid
Definition: postgres_ext.h:31
IndexAttrBitmapKind
Definition: relcache.h:54
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5278
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:2930
struct RelationData * Relation
Definition: relcache.h:26
unsigned short uint16
Definition: c.h:305
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:5983
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind keyAttrs)
Definition: relcache.c:4865
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6066
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4694
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3641
Relation * RelationPtr
Definition: relcache.h:34
void RelationSetNewRelfilenode(Relation relation, char persistence, TransactionId freezeXid, MultiXactId minmulti)
Definition: relcache.c:3433
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4719
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:2873
void RelationClose(Relation relation)
Definition: relcache.c:2170
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2726
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6092
bool criticalSharedRelcachesBuilt
Definition: relcache.c:131
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:5072
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4200
TransactionId MultiXactId
Definition: c.h:465
void RelationCacheInitialize(void)
Definition: relcache.c:3545
struct PublicationActions * GetRelationPublicationActions(Relation relation)
Definition: relcache.c:5190
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4673
void RelationCacheInvalidate(void)
Definition: relcache.c:2770
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:2081
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4503
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:3193
Definition: pg_list.h:45
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4782
Oid RelationGetOidIndex(Relation relation)
Definition: relcache.c:4645
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1518