]> granicus.if.org Git - postgresql/blob - src/include/utils/relcache.h
Add new to_reg* functions for error-free OID lookups.
[postgresql] / src / include / utils / relcache.h
1 /*-------------------------------------------------------------------------
2  *
3  * relcache.h
4  *        Relation descriptor cache definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2014, 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 *RelationGetIndexList(Relation relation);
41 extern Oid      RelationGetOidIndex(Relation relation);
42 extern List *RelationGetIndexExpressions(Relation relation);
43 extern List *RelationGetIndexPredicate(Relation relation);
44
45 typedef enum IndexAttrBitmapKind
46 {
47         INDEX_ATTR_BITMAP_ALL,
48         INDEX_ATTR_BITMAP_KEY,
49         INDEX_ATTR_BITMAP_IDENTITY_KEY
50 } IndexAttrBitmapKind;
51
52 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
53                                                                                          IndexAttrBitmapKind keyAttrs);
54
55 extern void RelationGetExclusionInfo(Relation indexRelation,
56                                                  Oid **operators,
57                                                  Oid **procs,
58                                                  uint16 **strategies);
59
60 extern void RelationSetIndexList(Relation relation,
61                                          List *indexIds, Oid oidIndex);
62
63 extern void RelationInitIndexAccessInfo(Relation relation);
64
65 /*
66  * Routines to support ereport() reports of relation-related errors
67  */
68 extern int      errtable(Relation rel);
69 extern int      errtablecol(Relation rel, int attnum);
70 extern int      errtablecolname(Relation rel, const char *colname);
71 extern int      errtableconstraint(Relation rel, const char *conname);
72
73 /*
74  * Routines for backend startup
75  */
76 extern void RelationCacheInitialize(void);
77 extern void RelationCacheInitializePhase2(void);
78 extern void RelationCacheInitializePhase3(void);
79
80 /*
81  * Routine to create a relcache entry for an about-to-be-created relation
82  */
83 extern Relation RelationBuildLocalRelation(const char *relname,
84                                                    Oid relnamespace,
85                                                    TupleDesc tupDesc,
86                                                    Oid relid,
87                                                    Oid relfilenode,
88                                                    Oid reltablespace,
89                                                    bool shared_relation,
90                                                    bool mapped_relation,
91                                                    char relpersistence,
92                                                    char relkind);
93
94 /*
95  * Routine to manage assignment of new relfilenode to a relation
96  */
97 extern void RelationSetNewRelfilenode(Relation relation,
98                                                   TransactionId freezeXid, MultiXactId minmulti);
99
100 /*
101  * Routines for flushing/rebuilding relcache entries in various scenarios
102  */
103 extern void RelationForgetRelation(Oid rid);
104
105 extern void RelationCacheInvalidateEntry(Oid relationId);
106
107 extern void RelationCacheInvalidate(void);
108
109 extern void RelationCloseSmgrByOid(Oid relationId);
110
111 extern void AtEOXact_RelationCache(bool isCommit);
112 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
113                                                   SubTransactionId parentSubid);
114
115 /*
116  * Routines to help manage rebuilding of relcache init files
117  */
118 extern bool RelationIdIsInInitFile(Oid relationId);
119 extern void RelationCacheInitFilePreInvalidate(void);
120 extern void RelationCacheInitFilePostInvalidate(void);
121 extern void RelationCacheInitFileRemove(void);
122
123 /* should be used only by relcache.c and catcache.c */
124 extern bool criticalRelcachesBuilt;
125
126 /* should be used only by relcache.c and postinit.c */
127 extern bool criticalSharedRelcachesBuilt;
128
129 #endif   /* RELCACHE_H */