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 | { |
55 | INDEX_ATTR_BITMAP_ALL, |
56 | INDEX_ATTR_BITMAP_KEY, |
57 | INDEX_ATTR_BITMAP_PRIMARY_KEY, |
58 | INDEX_ATTR_BITMAP_IDENTITY_KEY |
59 | } IndexAttrBitmapKind; |
60 | |
61 | extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation, |
62 | IndexAttrBitmapKind keyAttrs); |
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, |
100 | Oid relfilenode, |
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 */ |
142 | |