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 Oid RelationGetOidIndex(Relation relation);
43 extern Oid RelationGetPrimaryKeyIndex(Relation relation);
44 extern Oid RelationGetReplicaIndex(Relation relation);
45 extern List *RelationGetIndexExpressions(Relation relation);
46 extern List *RelationGetIndexPredicate(Relation relation);
47 
48 typedef enum IndexAttrBitmapKind
49 {
55 
56 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
57  IndexAttrBitmapKind keyAttrs);
58 
59 extern void RelationGetExclusionInfo(Relation indexRelation,
60  Oid **operators,
61  Oid **procs,
62  uint16 **strategies);
63 
64 extern void RelationSetIndexList(Relation relation,
65  List *indexIds, Oid oidIndex);
66 
67 extern void RelationInitIndexAccessInfo(Relation relation);
68 
69 /* caller must include pg_publication.h */
70 struct PublicationActions;
71 extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
72 
73 /*
74  * Routines to support ereport() reports of relation-related errors
75  */
76 extern int errtable(Relation rel);
77 extern int errtablecol(Relation rel, int attnum);
78 extern int errtablecolname(Relation rel, const char *colname);
79 extern int errtableconstraint(Relation rel, const char *conname);
80 
81 /*
82  * Routines for backend startup
83  */
84 extern void RelationCacheInitialize(void);
85 extern void RelationCacheInitializePhase2(void);
86 extern void RelationCacheInitializePhase3(void);
87 
88 /*
89  * Routine to create a relcache entry for an about-to-be-created relation
90  */
91 extern Relation RelationBuildLocalRelation(const char *relname,
92  Oid relnamespace,
93  TupleDesc tupDesc,
94  Oid relid,
95  Oid relfilenode,
96  Oid reltablespace,
97  bool shared_relation,
98  bool mapped_relation,
99  char relpersistence,
100  char relkind);
101 
102 /*
103  * Routine to manage assignment of new relfilenode to a relation
104  */
105 extern void RelationSetNewRelfilenode(Relation relation, char persistence,
106  TransactionId freezeXid, MultiXactId minmulti);
107 
108 /*
109  * Routines for flushing/rebuilding relcache entries in various scenarios
110  */
111 extern void RelationForgetRelation(Oid rid);
112 
113 extern void RelationCacheInvalidateEntry(Oid relationId);
114 
115 extern void RelationCacheInvalidate(void);
116 
117 extern void RelationCloseSmgrByOid(Oid relationId);
118 
119 extern void AtEOXact_RelationCache(bool isCommit);
120 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
121  SubTransactionId parentSubid);
122 
123 /*
124  * Routines to help manage rebuilding of relcache init files
125  */
126 extern bool RelationIdIsInInitFile(Oid relationId);
127 extern void RelationCacheInitFilePreInvalidate(void);
128 extern void RelationCacheInitFilePostInvalidate(void);
129 extern void RelationCacheInitFileRemove(void);
130 
131 /* should be used only by relcache.c and catcache.c */
132 extern bool criticalRelcachesBuilt;
133 
134 /* should be used only by relcache.c and postinit.c */
135 extern bool criticalSharedRelcachesBuilt;
136 
137 #endif /* RELCACHE_H */
void RelationCacheInitFileRemove(void)
Definition: relcache.c:5993
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3066
void RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex)
Definition: relcache.c:4509
int errtable(Relation rel)
Definition: relcache.c:5155
uint32 TransactionId
Definition: c.h:397
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5209
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3563
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5196
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4336
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2679
uint32 SubTransactionId
Definition: c.h:401
bool criticalRelcachesBuilt
Definition: relcache.c:128
unsigned int Oid
Definition: postgres_ext.h:31
IndexAttrBitmapKind
Definition: relcache.h:48
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5172
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:2915
struct RelationData * Relation
Definition: relcache.h:21
unsigned short uint16
Definition: c.h:267
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:5869
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind keyAttrs)
Definition: relcache.c:4759
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:5952
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4588
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3622
Relation * RelationPtr
Definition: relcache.h:29
void RelationSetNewRelfilenode(Relation relation, char persistence, TransactionId freezeXid, MultiXactId minmulti)
Definition: relcache.c:3414
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4613
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:2858
void RelationClose(Relation relation)
Definition: relcache.c:2155
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2711
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:5978
bool criticalSharedRelcachesBuilt
Definition: relcache.c:134
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:4966
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4173
TransactionId MultiXactId
Definition: c.h:407
void RelationCacheInitialize(void)
Definition: relcache.c:3526
struct PublicationActions * GetRelationPublicationActions(Relation relation)
Definition: relcache.c:5084
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4567
void RelationCacheInvalidate(void)
Definition: relcache.c:2755
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:2066
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:3178
Definition: pg_list.h:45
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4676
Oid RelationGetOidIndex(Relation relation)
Definition: relcache.c:4539
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1504