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-2019, 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 RelationGetPrimaryKeyIndex(Relation relation);
49 extern Oid RelationGetReplicaIndex(Relation relation);
50 extern List *RelationGetIndexExpressions(Relation relation);
51 extern List *RelationGetDummyIndexExpressions(Relation relation);
52 extern List *RelationGetIndexPredicate(Relation relation);
53 
54 typedef enum IndexAttrBitmapKind
55 {
61 
62 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
63  IndexAttrBitmapKind attrKind);
64 
65 extern void RelationGetExclusionInfo(Relation indexRelation,
66  Oid **operators,
67  Oid **procs,
68  uint16 **strategies);
69 
70 extern void RelationInitIndexAccessInfo(Relation relation);
71 
72 /* caller must include pg_publication.h */
73 struct PublicationActions;
74 extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
75 
76 extern void RelationInitTableAccessMethod(Relation relation);
77 
78 /*
79  * Routines to support ereport() reports of relation-related errors
80  */
81 extern int errtable(Relation rel);
82 extern int errtablecol(Relation rel, int attnum);
83 extern int errtablecolname(Relation rel, const char *colname);
84 extern int errtableconstraint(Relation rel, const char *conname);
85 
86 /*
87  * Routines for backend startup
88  */
89 extern void RelationCacheInitialize(void);
90 extern void RelationCacheInitializePhase2(void);
91 extern void RelationCacheInitializePhase3(void);
92 
93 /*
94  * Routine to create a relcache entry for an about-to-be-created relation
95  */
96 extern Relation RelationBuildLocalRelation(const char *relname,
97  Oid relnamespace,
98  TupleDesc tupDesc,
99  Oid relid,
100  Oid accessmtd,
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 
113 /*
114  * Routines for flushing/rebuilding relcache entries in various scenarios
115  */
116 extern void RelationForgetRelation(Oid rid);
117 
118 extern void RelationCacheInvalidateEntry(Oid relationId);
119 
120 extern void RelationCacheInvalidate(void);
121 
122 extern void RelationCloseSmgrByOid(Oid relationId);
123 
124 extern void AtEOXact_RelationCache(bool isCommit);
125 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
126  SubTransactionId parentSubid);
127 
128 /*
129  * Routines to help manage rebuilding of relcache init files
130  */
131 extern bool RelationIdIsInInitFile(Oid relationId);
132 extern void RelationCacheInitFilePreInvalidate(void);
133 extern void RelationCacheInitFilePostInvalidate(void);
134 extern void RelationCacheInitFileRemove(void);
135 
136 /* should be used only by relcache.c and catcache.c */
137 extern bool criticalRelcachesBuilt;
138 
139 /* should be used only by relcache.c and postinit.c */
140 extern bool criticalSharedRelcachesBuilt;
141 
142 #endif /* RELCACHE_H */
void RelationCacheInitFileRemove(void)
Definition: relcache.c:6029
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3076
List * RelationGetDummyIndexExpressions(Relation relation)
Definition: relcache.c:4640
int errtable(Relation rel)
Definition: relcache.c:5218
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5272
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3616
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5259
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4347
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2702
uint32 SubTransactionId
Definition: c.h:518
bool criticalRelcachesBuilt
Definition: relcache.c:140
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
IndexAttrBitmapKind
Definition: relcache.h:54
char relkind
Definition: pg_class.h:81
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5235
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:2938
struct RelationData * Relation
Definition: relcache.h:26
unsigned short uint16
Definition: c.h:358
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:5949
char relpersistence
Definition: pg_class.h:78
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:5989
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4556
void RelationInitTableAccessMethod(Relation relation)
Definition: relcache.c:1739
Oid relfilenode
Definition: pg_class.h:54
Relation RelationBuildLocalRelation(const char *relname, Oid relnamespace, TupleDesc tupDesc, Oid relid, Oid accessmtd, Oid relfilenode, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence, char relkind)
Definition: relcache.c:3175
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3675
Relation * RelationPtr
Definition: relcache.h:34
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4581
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:2881
void RelationClose(Relation relation)
Definition: relcache.c:2088
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2734
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6014
bool criticalSharedRelcachesBuilt
Definition: relcache.c:146
int16 attnum
Definition: pg_attribute.h:79
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:5015
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4238
void RelationCacheInitialize(void)
Definition: relcache.c:3579
struct PublicationActions * GetRelationPublicationActions(Relation relation)
Definition: relcache.c:5139
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Definition: relcache.c:4777
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4535
void RelationCacheInvalidate(void)
Definition: relcache.c:2778
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:1989
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4466
Definition: pg_list.h:50
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4694
void RelationSetNewRelfilenode(Relation relation, char persistence)
Definition: relcache.c:3417
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1361