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-2024, 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 "common/relpath.h"
19 #include "nodes/bitmapset.h"
20 
21 
22 /*
23  * Name of relcache init file(s), used to speed up backend startup
24  */
25 #define RELCACHE_INIT_FILENAME "pg_internal.init"
26 
27 typedef struct RelationData *Relation;
28 
29 /* ----------------
30  * RelationPtr is used in the executor to support index scans
31  * where we have to keep track of several index relations in an
32  * array. -cim 9/10/89
33  * ----------------
34  */
36 
37 /*
38  * Routines to open (lookup) and close a relcache entry
39  */
40 extern Relation RelationIdGetRelation(Oid relationId);
41 extern void RelationClose(Relation relation);
42 
43 /*
44  * Routines to compute/retrieve additional cached information
45  */
46 extern List *RelationGetFKeyList(Relation relation);
47 extern List *RelationGetIndexList(Relation relation);
48 extern List *RelationGetStatExtList(Relation relation);
49 extern Oid RelationGetPrimaryKeyIndex(Relation relation);
50 extern Oid RelationGetReplicaIndex(Relation relation);
51 extern List *RelationGetIndexExpressions(Relation relation);
53 extern List *RelationGetIndexPredicate(Relation relation);
54 extern bytea **RelationGetIndexAttOptions(Relation relation, bool copy);
55 
56 /*
57  * Which set of columns to return by RelationGetIndexAttrBitmap.
58  */
59 typedef enum IndexAttrBitmapKind
60 {
67 
69  IndexAttrBitmapKind attrKind);
70 
72 
73 extern void RelationGetExclusionInfo(Relation indexRelation,
74  Oid **operators,
75  Oid **procs,
76  uint16 **strategies);
77 
78 extern void RelationInitIndexAccessInfo(Relation relation);
79 
80 /* caller must include pg_publication.h */
81 struct PublicationDesc;
82 extern void RelationBuildPublicationDesc(Relation relation,
83  struct PublicationDesc *pubdesc);
84 
85 extern void RelationInitTableAccessMethod(Relation relation);
86 
87 /*
88  * Routines to support ereport() reports of relation-related errors
89  */
90 extern int errtable(Relation rel);
91 extern int errtablecol(Relation rel, int attnum);
92 extern int errtablecolname(Relation rel, const char *colname);
93 extern int errtableconstraint(Relation rel, const char *conname);
94 
95 /*
96  * Routines for backend startup
97  */
98 extern void RelationCacheInitialize(void);
99 extern void RelationCacheInitializePhase2(void);
100 extern void RelationCacheInitializePhase3(void);
101 
102 /*
103  * Routine to create a relcache entry for an about-to-be-created relation
104  */
105 extern Relation RelationBuildLocalRelation(const char *relname,
106  Oid relnamespace,
107  TupleDesc tupDesc,
108  Oid relid,
109  Oid accessmtd,
110  RelFileNumber relfilenumber,
111  Oid reltablespace,
112  bool shared_relation,
113  bool mapped_relation,
114  char relpersistence,
115  char relkind);
116 
117 /*
118  * Routines to manage assignment of new relfilenumber to a relation
119  */
120 extern void RelationSetNewRelfilenumber(Relation relation, char persistence);
121 extern void RelationAssumeNewRelfilelocator(Relation relation);
122 
123 /*
124  * Routines for flushing/rebuilding relcache entries in various scenarios
125  */
126 extern void RelationForgetRelation(Oid rid);
127 
128 extern void RelationCacheInvalidateEntry(Oid relationId);
129 
130 extern void RelationCacheInvalidate(bool debug_discard);
131 
132 #ifdef USE_ASSERT_CHECKING
133 extern void AssertPendingSyncs_RelationCache(void);
134 #else
135 #define AssertPendingSyncs_RelationCache() do {} while (0)
136 #endif
137 extern void AtEOXact_RelationCache(bool isCommit);
138 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
139  SubTransactionId parentSubid);
140 
141 /*
142  * Routines to help manage rebuilding of relcache init files
143  */
144 extern bool RelationIdIsInInitFile(Oid relationId);
145 extern void RelationCacheInitFilePreInvalidate(void);
146 extern void RelationCacheInitFilePostInvalidate(void);
147 extern void RelationCacheInitFileRemove(void);
148 
149 /* should be used only by relcache.c and catcache.c */
151 
152 /* should be used only by relcache.c and postinit.c */
154 
155 #endif /* RELCACHE_H */
unsigned short uint16
Definition: c.h:505
#define PGDLLIMPORT
Definition: c.h:1316
uint32 SubTransactionId
Definition: c.h:656
int16 attnum
Definition: pg_attribute.h:74
NameData relname
Definition: pg_class.h:38
unsigned int Oid
Definition: postgres_ext.h:31
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4760
void RelationCacheInvalidate(bool debug_discard)
Definition: relcache.c:2973
struct RelationData * Relation
Definition: relcache.h:27
PGDLLIMPORT bool criticalRelcachesBuilt
Definition: relcache.c:140
Oid RelationGetPrimaryKeyIndex(Relation relation)
Definition: relcache.c:4951
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:5965
int errtablecol(Relation rel, int attnum)
Definition: relcache.c:5928
IndexAttrBitmapKind
Definition: relcache.h:60
@ INDEX_ATTR_BITMAP_KEY
Definition: relcache.h:61
@ INDEX_ATTR_BITMAP_HOT_BLOCKING
Definition: relcache.h:64
@ INDEX_ATTR_BITMAP_PRIMARY_KEY
Definition: relcache.h:62
@ INDEX_ATTR_BITMAP_SUMMARIZED
Definition: relcache.h:65
@ INDEX_ATTR_BITMAP_IDENTITY_KEY
Definition: relcache.h:63
PGDLLIMPORT bool criticalSharedRelcachesBuilt
Definition: relcache.c:146
void RelationInitIndexAccessInfo(Relation relation)
Definition: relcache.c:1425
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:5110
List * RelationGetStatExtList(Relation relation)
Definition: relcache.c:4881
void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: relcache.c:3346
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6745
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Definition: relcache.c:5203
void RelationCacheInitializePhase3(void)
Definition: relcache.c:4056
List * RelationGetDummyIndexExpressions(Relation relation)
Definition: relcache.c:5056
List * RelationGetFKeyList(Relation relation)
Definition: relcache.c:4651
void RelationInitTableAccessMethod(Relation relation)
Definition: relcache.c:1809
void RelationBuildPublicationDesc(Relation relation, struct PublicationDesc *pubdesc)
Definition: relcache.c:5682
void RelationSetNewRelfilenumber(Relation relation, char persistence)
Definition: relcache.c:3726
#define AssertPendingSyncs_RelationCache()
Definition: relcache.h:135
Oid RelationGetReplicaIndex(Relation relation)
Definition: relcache.c:4972
Relation RelationIdGetRelation(Oid relationId)
Definition: relcache.c:2062
void AtEOXact_RelationCache(bool isCommit)
Definition: relcache.c:3194
void RelationForgetRelation(Oid rid)
Definition: relcache.c:2873
void RelationCacheInitialize(void)
Definition: relcache.c:3951
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6720
Relation RelationBuildLocalRelation(const char *relname, Oid relnamespace, TupleDesc tupDesc, Oid relid, Oid accessmtd, RelFileNumber relfilenumber, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence, char relkind)
Definition: relcache.c:3483
void RelationAssumeNewRelfilelocator(Relation relation)
Definition: relcache.c:3925
void RelationCacheInitFileRemove(void)
Definition: relcache.c:6760
int errtablecolname(Relation rel, const char *colname)
Definition: relcache.c:5952
void RelationCacheInitializePhase2(void)
Definition: relcache.c:3997
bool RelationIdIsInInitFile(Oid relationId)
Definition: relcache.c:6680
int errtable(Relation rel)
Definition: relcache.c:5911
void RelationCacheInvalidateEntry(Oid relationId)
Definition: relcache.c:2917
bytea ** RelationGetIndexAttOptions(Relation relation, bool copy)
Definition: relcache.c:5850
Bitmapset * RelationGetIdentityKeyBitmap(Relation relation)
Definition: relcache.c:5476
void RelationGetExclusionInfo(Relation indexRelation, Oid **operators, Oid **procs, uint16 **strategies)
Definition: relcache.c:5550
Relation * RelationPtr
Definition: relcache.h:35
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:4997
void RelationClose(Relation relation)
Definition: relcache.c:2193
Oid RelFileNumber
Definition: relpath.h:25
Definition: pg_list.h:54
Definition: c.h:687