codekingpro/portable-devtools
116k
1/*-------------------------------------------------------------------------2 *3 * relcache.h4 * Relation descriptor cache definitions.5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/utils/relcache.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef RELCACHE_H15#define RELCACHE_H16 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 startup24 */25#define RELCACHE_INIT_FILENAME "pg_internal.init"26 27typedef struct RelationData *Relation;28 29/* ----------------30 * RelationPtr is used in the executor to support index scans31 * where we have to keep track of several index relations in an32 * array. -cim 9/10/8933 * ----------------34 */35typedef Relation *RelationPtr;36 37/*38 * Routines to open (lookup) and close a relcache entry39 */40extern Relation RelationIdGetRelation(Oid relationId);41extern void RelationClose(Relation relation);42 43/*44 * Routines to compute/retrieve additional cached information45 */46extern List *RelationGetFKeyList(Relation relation);47extern List *RelationGetIndexList(Relation relation);48extern List *RelationGetStatExtList(Relation relation);49extern Oid RelationGetPrimaryKeyIndex(Relation relation);50extern Oid RelationGetReplicaIndex(Relation relation);51extern List *RelationGetIndexExpressions(Relation relation);52extern List *RelationGetDummyIndexExpressions(Relation relation);53extern List *RelationGetIndexPredicate(Relation relation);54extern Datum *RelationGetIndexRawAttOptions(Relation indexrel);55extern bytea **RelationGetIndexAttOptions(Relation relation, bool copy);56 57/*58 * Which set of columns to return by RelationGetIndexAttrBitmap.59 */60typedef enum IndexAttrBitmapKind61{62 INDEX_ATTR_BITMAP_KEY,63 INDEX_ATTR_BITMAP_PRIMARY_KEY,64 INDEX_ATTR_BITMAP_IDENTITY_KEY,65 INDEX_ATTR_BITMAP_HOT_BLOCKING,66 INDEX_ATTR_BITMAP_SUMMARIZED67} IndexAttrBitmapKind;68 69extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,70 IndexAttrBitmapKind attrKind);71 72extern Bitmapset *RelationGetIdentityKeyBitmap(Relation relation);73 74extern void RelationGetExclusionInfo(Relation indexRelation,75 Oid **operators,76 Oid **procs,77 uint16 **strategies);78 79extern void RelationInitIndexAccessInfo(Relation relation);80 81/* caller must include pg_publication.h */82struct PublicationDesc;83extern void RelationBuildPublicationDesc(Relation relation,84 struct PublicationDesc *pubdesc);85 86extern void RelationInitTableAccessMethod(Relation relation);87 88/*89 * Routines to support ereport() reports of relation-related errors90 */91extern int errtable(Relation rel);92extern int errtablecol(Relation rel, int attnum);93extern int errtablecolname(Relation rel, const char *colname);94extern int errtableconstraint(Relation rel, const char *conname);95 96/*97 * Routines for backend startup98 */99extern void RelationCacheInitialize(void);100extern void RelationCacheInitializePhase2(void);101extern void RelationCacheInitializePhase3(void);102 103/*104 * Routine to create a relcache entry for an about-to-be-created relation105 */106extern Relation RelationBuildLocalRelation(const char *relname,107 Oid relnamespace,108 TupleDesc tupDesc,109 Oid relid,110 Oid accessmtd,111 RelFileNumber relfilenumber,112 Oid reltablespace,113 bool shared_relation,114 bool mapped_relation,115 char relpersistence,116 char relkind);117 118/*119 * Routines to manage assignment of new relfilenumber to a relation120 */121extern void RelationSetNewRelfilenumber(Relation relation, char persistence);122extern void RelationAssumeNewRelfilelocator(Relation relation);123 124/*125 * Routines for flushing/rebuilding relcache entries in various scenarios126 */127extern void RelationForgetRelation(Oid rid);128 129extern void RelationCacheInvalidateEntry(Oid relationId);130 131extern void RelationCacheInvalidate(bool debug_discard);132 133extern void RelationCloseSmgrByOid(Oid relationId);134 135#ifdef USE_ASSERT_CHECKING136extern void AssertPendingSyncs_RelationCache(void);137#else138#define AssertPendingSyncs_RelationCache() do {} while (0)139#endif140extern void AtEOXact_RelationCache(bool isCommit);141extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,142 SubTransactionId parentSubid);143 144/*145 * Routines to help manage rebuilding of relcache init files146 */147extern bool RelationIdIsInInitFile(Oid relationId);148extern void RelationCacheInitFilePreInvalidate(void);149extern void RelationCacheInitFilePostInvalidate(void);150extern void RelationCacheInitFileRemove(void);151 152/* should be used only by relcache.c and catcache.c */153extern PGDLLIMPORT bool criticalRelcachesBuilt;154 155/* should be used only by relcache.c and postinit.c */156extern PGDLLIMPORT bool criticalSharedRelcachesBuilt;157 158#endif /* RELCACHE_H */159 