Header And Logo

PostgreSQL
| The world's most advanced open source database.

relcache.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * relcache.h
00004  *    Relation descriptor cache definitions.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/utils/relcache.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef RELCACHE_H
00015 #define RELCACHE_H
00016 
00017 #include "access/tupdesc.h"
00018 #include "nodes/bitmapset.h"
00019 
00020 
00021 typedef struct RelationData *Relation;
00022 
00023 /* ----------------
00024  *      RelationPtr is used in the executor to support index scans
00025  *      where we have to keep track of several index relations in an
00026  *      array.  -cim 9/10/89
00027  * ----------------
00028  */
00029 typedef Relation *RelationPtr;
00030 
00031 /*
00032  * Routines to open (lookup) and close a relcache entry
00033  */
00034 extern Relation RelationIdGetRelation(Oid relationId);
00035 extern void RelationClose(Relation relation);
00036 
00037 /*
00038  * Routines to compute/retrieve additional cached information
00039  */
00040 extern List *RelationGetIndexList(Relation relation);
00041 extern Oid  RelationGetOidIndex(Relation relation);
00042 extern List *RelationGetIndexExpressions(Relation relation);
00043 extern List *RelationGetIndexPredicate(Relation relation);
00044 extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation, bool keyAttrs);
00045 extern void RelationGetExclusionInfo(Relation indexRelation,
00046                          Oid **operators,
00047                          Oid **procs,
00048                          uint16 **strategies);
00049 
00050 extern void RelationSetIndexList(Relation relation,
00051                      List *indexIds, Oid oidIndex);
00052 
00053 extern void RelationInitIndexAccessInfo(Relation relation);
00054 
00055 /*
00056  * Routines to support ereport() reports of relation-related errors
00057  */
00058 extern int  errtable(Relation rel);
00059 extern int  errtablecol(Relation rel, int attnum);
00060 extern int  errtablecolname(Relation rel, const char *colname);
00061 extern int  errtableconstraint(Relation rel, const char *conname);
00062 
00063 /*
00064  * Routines for backend startup
00065  */
00066 extern void RelationCacheInitialize(void);
00067 extern void RelationCacheInitializePhase2(void);
00068 extern void RelationCacheInitializePhase3(void);
00069 
00070 /*
00071  * Routine to create a relcache entry for an about-to-be-created relation
00072  */
00073 extern Relation RelationBuildLocalRelation(const char *relname,
00074                            Oid relnamespace,
00075                            TupleDesc tupDesc,
00076                            Oid relid,
00077                            Oid relfilenode,
00078                            Oid reltablespace,
00079                            bool shared_relation,
00080                            bool mapped_relation,
00081                            char relpersistence,
00082                            char relkind);
00083 
00084 /*
00085  * Routine to manage assignment of new relfilenode to a relation
00086  */
00087 extern void RelationSetNewRelfilenode(Relation relation,
00088                           TransactionId freezeXid, MultiXactId minmulti);
00089 
00090 /*
00091  * Routines for flushing/rebuilding relcache entries in various scenarios
00092  */
00093 extern void RelationForgetRelation(Oid rid);
00094 
00095 extern void RelationCacheInvalidateEntry(Oid relationId);
00096 
00097 extern void RelationCacheInvalidate(void);
00098 
00099 extern void RelationCloseSmgrByOid(Oid relationId);
00100 
00101 extern void AtEOXact_RelationCache(bool isCommit);
00102 extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
00103                           SubTransactionId parentSubid);
00104 
00105 /*
00106  * Routines to help manage rebuilding of relcache init files
00107  */
00108 extern bool RelationIdIsInInitFile(Oid relationId);
00109 extern void RelationCacheInitFilePreInvalidate(void);
00110 extern void RelationCacheInitFilePostInvalidate(void);
00111 extern void RelationCacheInitFileRemove(void);
00112 
00113 /* should be used only by relcache.c and catcache.c */
00114 extern bool criticalRelcachesBuilt;
00115 
00116 /* should be used only by relcache.c and postinit.c */
00117 extern bool criticalSharedRelcachesBuilt;
00118 
00119 #endif   /* RELCACHE_H */