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 *RelationGetIndexPredicate(Relation relation);
52 
53 typedef enum IndexAttrBitmapKind
54 {
60 
61 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
62  IndexAttrBitmapKind attrKind);
63 
64 extern void RelationGetExclusionInfo(Relation indexRelation,
65  Oid **operators,
66  Oid **procs,
67  uint16 **strategies);
68 
69 extern void RelationInitIndexAccessInfo(Relation relation);
70 
71 /* caller must include pg_publication.h */
72 struct PublicationActions;
73 extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
74 
75 extern void RelationInitTableAccessMethod(Relation relation);
76 
77 /*
78  * Routines to support ereport() reports of relation-related errors
79  */
80 extern int errtable(Relation rel);
81 extern int errtablecol(Relation rel, int attnum);
82 extern int errtablecolname(Relation rel, const char *colname);
83 extern int errtableconstraint(Relation rel, const char *conname);
84 
85 /*
86  * Routines for backend startup
87  */
88 extern void RelationCacheInitialize(void);
89 extern void RelationCacheInitializePhase2(void);
90 extern void RelationCacheInitializePhase3(void);
91 
92 /*
93  * Routine to create a relcache entry for an about-to-be-created relation
94  */
95 extern Relation RelationBuildLocalRelation(const char *relname,
96  Oid relnamespace,
97  TupleDesc tupDesc,
98  Oid relid,
99  Oid accessmtd,
101  Oid reltablespace,
102  bool shared_relation,
103  bool mapped_relation,
104  char relpersistence,
105  char relkind);
106 
107 /*
108  * Routine to manage assignment of new relfilenode to a relation
109  */
110 extern void RelationSetNewRelfilenode(Relation relation, char persistence);
111 
112 /*
113  * Routines for flushing/rebuilding relcache entries in various scenarios
114  */
115 extern void RelationForgetRelation(Oid rid);
116 
117 extern void RelationCacheInvalidateEntry(Oid relationId);
118 
119 extern void RelationCacheInvalidate(void);
120 
121 extern void RelationCloseSmgrByOid(Oid relationId);
122 
123 extern void AtEOXact_RelationCache(bool isCommit);
124 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
125  SubTransactionId parentSubid);
126 
127 /*
128  * Routines to help manage rebuilding of relcache init files
129  */
130 extern bool RelationIdIsInInitFile(Oid relationId);
131 extern void RelationCacheInitFilePreInvalidate(void);
132 extern void RelationCacheInitFilePostInvalidate(void);
133 extern void RelationCacheInitFileRemove(void);
134 
135 /* should be used only by relcache.c and catcache.c */
136 extern bool criticalRelcachesBuilt;
137 
138 /* should be used only by relcache.c and postinit.c */
139 extern bool criticalSharedRelcachesBuilt;
140 
141 #endif /* RELCACHE_H */
void RelationCacheInitFileRemove(void)
Definition: relcache.c:5979
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3077
int errtable(Relation rel)
Definition: relcache.c:5168
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5222
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3617
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5209
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4348
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2703
uint32 SubTransactionId
Definition: c.h:511
bool criticalRelcachesBuilt
Definition: relcache.c:141
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
IndexAttrBitmapKind
Definition: relcache.h:53
char relkind
Definition: pg_class.h:81
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5185
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:2939
struct RelationData * Relation
Definition: relcache.h:26
unsigned short uint16
Definition: c.h:357
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:5899
char relpersistence
Definition: pg_class.h:78
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:5939
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4557
void RelationInitTableAccessMethod(Relation relation)
Definition: relcache.c:1740
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:3176
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3676
Relation * RelationPtr
Definition: relcache.h:34
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4582
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:2882
void RelationClose(Relation relation)
Definition: relcache.c:2089
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2735
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:5964
bool criticalSharedRelcachesBuilt
Definition: relcache.c:147
int16 attnum
Definition: pg_attribute.h:79
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:4965
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4239
void RelationCacheInitialize(void)
Definition: relcache.c:3580
struct PublicationActions * GetRelationPublicationActions(Relation relation)
Definition: relcache.c:5089
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Definition: relcache.c:4727
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4536
void RelationCacheInvalidate(void)
Definition: relcache.c:2779
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:1990
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4467
Definition: pg_list.h:50
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4644
void RelationSetNewRelfilenode(Relation relation, char persistence)
Definition: relcache.c:3418
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1362