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-2022, 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  */
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);
52 extern List *RelationGetIndexPredicate(Relation relation);
54 extern bytea **RelationGetIndexAttOptions(Relation relation, bool copy);
55 
56 typedef enum IndexAttrBitmapKind
57 {
63 
65  IndexAttrBitmapKind attrKind);
66 
68 
69 extern void RelationGetExclusionInfo(Relation indexRelation,
70  Oid **operators,
71  Oid **procs,
72  uint16 **strategies);
73 
74 extern void RelationInitIndexAccessInfo(Relation relation);
75 
76 /* caller must include pg_publication.h */
77 struct PublicationDesc;
78 extern void RelationBuildPublicationDesc(Relation relation,
79  struct PublicationDesc *pubdesc);
80 
81 extern void RelationInitTableAccessMethod(Relation relation);
82 
83 /*
84  * Routines to support ereport() reports of relation-related errors
85  */
86 extern int errtable(Relation rel);
87 extern int errtablecol(Relation rel, int attnum);
88 extern int errtablecolname(Relation rel, const char *colname);
89 extern int errtableconstraint(Relation rel, const char *conname);
90 
91 /*
92  * Routines for backend startup
93  */
94 extern void RelationCacheInitialize(void);
95 extern void RelationCacheInitializePhase2(void);
96 extern void RelationCacheInitializePhase3(void);
97 
98 /*
99  * Routine to create a relcache entry for an about-to-be-created relation
100  */
101 extern Relation RelationBuildLocalRelation(const char *relname,
102  Oid relnamespace,
103  TupleDesc tupDesc,
104  Oid relid,
105  Oid accessmtd,
106  Oid relfilenode,
107  Oid reltablespace,
108  bool shared_relation,
109  bool mapped_relation,
110  char relpersistence,
111  char relkind);
112 
113 /*
114  * Routines to manage assignment of new relfilenode to a relation
115  */
116 extern void RelationSetNewRelfilenode(Relation relation, char persistence);
117 extern void RelationAssumeNewRelfilenode(Relation relation);
118 
119 /*
120  * Routines for flushing/rebuilding relcache entries in various scenarios
121  */
122 extern void RelationForgetRelation(Oid rid);
123 
124 extern void RelationCacheInvalidateEntry(Oid relationId);
125 
126 extern void RelationCacheInvalidate(bool debug_discard);
127 
128 extern void RelationCloseSmgrByOid(Oid relationId);
129 
130 #ifdef USE_ASSERT_CHECKING
131 extern void AssertPendingSyncs_RelationCache(void);
132 #else
133 #define AssertPendingSyncs_RelationCache() do {} while (0)
134 #endif
135 extern void AtEOXact_RelationCache(bool isCommit);
136 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
137  SubTransactionId parentSubid);
138 
139 /*
140  * Routines to help manage rebuilding of relcache init files
141  */
142 extern bool RelationIdIsInInitFile(Oid relationId);
143 extern void RelationCacheInitFilePreInvalidate(void);
144 extern void RelationCacheInitFilePostInvalidate(void);
145 extern void RelationCacheInitFileRemove(void);
146 
147 /* should be used only by relcache.c and catcache.c */
149 
150 /* should be used only by relcache.c and postinit.c */
152 
153 #endif /* RELCACHE_H */
unsigned short uint16
Definition: c.h:440
#define PGDLLIMPORT
Definition: c.h:1331
uint32 SubTransactionId
Definition: c.h:591
int16 attnum
Definition: pg_attribute.h:83
NameData relname
Definition: pg_class.h:38
uintptr_t Datum
Definition: postgres.h:411
unsigned int Oid
Definition: postgres_ext.h:31
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4675
void RelationCacheInvalidate(bool debug_discard)
Definition: relcache.c:2924
Datum * RelationGetIndexRawAttOptions(Relation relation)
Definition: relcache.c:5712
struct RelationData * Relation
Definition: relcache.h:26
PGDLLIMPORT bool criticalRelcachesBuilt
Definition: relcache.c:139
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4863
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5873
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5836
IndexAttrBitmapKind
Definition: relcache.h:57
@ INDEX_ATTR_BITMAP_KEY
Definition: relcache.h:58
@ INDEX_ATTR_BITMAP_HOT_BLOCKING
Definition: relcache.h:61
@ INDEX_ATTR_BITMAP_PRIMARY_KEY
Definition: relcache.h:59
@ INDEX_ATTR_BITMAP_IDENTITY_KEY
Definition: relcache.h:60
PGDLLIMPORT bool criticalSharedRelcachesBuilt
Definition: relcache.c:145
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1416
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:5022
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4794
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3320
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6646
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Definition: relcache.c:5105
void RelationCacheInitializePhase3(void)
Definition: relcache.c:3975
List * RelationGetDummyIndexExpressions(Relation relation)
Definition: relcache.c:4968
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:3457
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4566
void RelationInitTableAccessMethod(Relation relation)
Definition: relcache.c:1800
void RelationBuildPublicationDesc(Relation relation, struct PublicationDesc *pubdesc)
Definition: relcache.c:5561
void RelationSetNewRelfilenode(Relation relation, char persistence)
Definition: relcache.c:3700
#define AssertPendingSyncs_RelationCache()
Definition: relcache.h:133
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4884
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:2053
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:3168
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2824
void RelationCacheInitialize(void)
Definition: relcache.c:3870
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6621
void RelationCacheInitFileRemove(void)
Definition: relcache.c:6661
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5860
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3916
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:6581
int errtable(Relation rel)
Definition: relcache.c:5819
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2868
bytea ** RelationGetIndexAttOptions(Relation relation, bool copy)
Definition: relcache.c:5758
Bitmapset * RelationGetIdentityKeyBitmap(Relation relation)
Definition: relcache.c:5355
void RelationCloseSmgrByOid(Oid relationId)
Definition: relcache.c:3033
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:5429
Relation * RelationPtr
Definition: relcache.h:34
void RelationAssumeNewRelfilenode(Relation relation)
Definition: relcache.c:3844
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4909
void RelationClose(Relation relation)
Definition: relcache.c:2159
Definition: pg_list.h:51
Definition: c.h:622