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-2018, 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 {
62 
63 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
64  IndexAttrBitmapKind keyAttrs);
65 
66 extern void RelationGetExclusionInfo(Relation indexRelation,
67  Oid **operators,
68  Oid **procs,
69  uint16 **strategies);
70 
71 extern void RelationSetIndexList(Relation relation,
72  List *indexIds, Oid oidIndex);
73 
74 extern void RelationInitIndexAccessInfo(Relation relation);
75 
76 /* caller must include pg_publication.h */
77 struct PublicationActions;
78 extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
79 
80 /*
81  * Routines to support ereport() reports of relation-related errors
82  */
83 extern int errtable(Relation rel);
84 extern int errtablecol(Relation rel, int attnum);
85 extern int errtablecolname(Relation rel, const char *colname);
86 extern int errtableconstraint(Relation rel, const char *conname);
87 
88 /*
89  * Routines for backend startup
90  */
91 extern void RelationCacheInitialize(void);
92 extern void RelationCacheInitializePhase2(void);
93 extern void RelationCacheInitializePhase3(void);
94 
95 /*
96  * Routine to create a relcache entry for an about-to-be-created relation
97  */
98 extern Relation RelationBuildLocalRelation(const char *relname,
100  TupleDesc tupDesc,
101  Oid relid,
104  bool shared_relation,
105  bool mapped_relation,
106  char relpersistence,
107  char relkind);
108 
109 /*
110  * Routine to manage assignment of new relfilenode to a relation
111  */
112 extern void RelationSetNewRelfilenode(Relation relation, char persistence,
113  TransactionId freezeXid, MultiXactId minmulti);
114 
115 /*
116  * Routines for flushing/rebuilding relcache entries in various scenarios
117  */
118 extern void RelationForgetRelation(Oid rid);
119 
120 extern void RelationCacheInvalidateEntry(Oid relationId);
121 
122 extern void RelationCacheInvalidate(void);
123 
124 extern void RelationCloseSmgrByOid(Oid relationId);
125 
126 extern void AtEOXact_RelationCache(bool isCommit);
127 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
128  SubTransactionId parentSubid);
129 
130 /*
131  * Routines to help manage rebuilding of relcache init files
132  */
133 extern bool RelationIdIsInInitFile(Oid relationId);
134 extern void RelationCacheInitFilePreInvalidate(void);
135 extern void RelationCacheInitFilePostInvalidate(void);
136 extern void RelationCacheInitFileRemove(void);
137 
138 /* should be used only by relcache.c and catcache.c */
139 extern bool criticalRelcachesBuilt;
140 
141 /* should be used only by relcache.c and postinit.c */
142 extern bool criticalSharedRelcachesBuilt;
143 
144 #endif /* RELCACHE_H */
void RelationCacheInitFileRemove(void)
Definition: relcache.c:6047
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:2912
Oid relnamespace
Definition: pg_class.h:32
void RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex)
Definition: relcache.c:4441
int errtable(Relation rel)
Definition: relcache.c:5193
uint32 TransactionId
Definition: c.h:474
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5247
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3413
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5234
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4190
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2525
uint32 SubTransactionId
Definition: c.h:478
bool criticalRelcachesBuilt
Definition: relcache.c:131
unsigned int Oid
Definition: postgres_ext.h:31
IndexAttrBitmapKind
Definition: relcache.h:54
char relkind
Definition: pg_class.h:51
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5210
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:2761
struct RelationData * Relation
Definition: relcache.h:26
unsigned short uint16
Definition: c.h:324
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:5923
char relpersistence
Definition: pg_class.h:50
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind keyAttrs)
Definition: relcache.c:4759
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6006
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4521
Oid relfilenode
Definition: pg_class.h:39
Oid reltablespace
Definition: pg_class.h:42
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3472
Relation * RelationPtr
Definition: relcache.h:34
void RelationSetNewRelfilenode(Relation relation, char persistence, TransactionId freezeXid, MultiXactId minmulti)
Definition: relcache.c:3264
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4546
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:2704
void RelationClose(Relation relation)
Definition: relcache.c:1996
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2557
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6032
bool criticalSharedRelcachesBuilt
Definition: relcache.c:137
int16 attnum
Definition: pg_attribute.h:79
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:5001
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4027
TransactionId MultiXactId
Definition: c.h:484
void RelationCacheInitialize(void)
Definition: relcache.c:3376
struct PublicationActions * GetRelationPublicationActions(Relation relation)
Definition: relcache.c:5121
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4500
void RelationCacheInvalidate(void)
Definition: relcache.c:2601
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:1906
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4330
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:3024
Definition: pg_list.h:45
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4608
Oid RelationGetOidIndex(Relation relation)
Definition: relcache.c:4472
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1343