mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Commit f3b5565dd4
was a couple of bricks shy
of a load; specifically, it missed putting pg_trigger_tgrelid_tgname_index
into the relcache init file, because that index is not used by any
syscache. However, we have historically nailed that index into cache for
performance reasons. The upshot was that load_relcache_init_file always
decided that the init file was busted and silently ignored it, resulting
in a significant hit to backend startup speed.
To fix, reinstantiate RelationIdIsInInitFile() as a wrapper around
RelationSupportsSysCache(), which can know about additional relations
that should be in the init file despite being unknown to syscache.c.
Also install some guards against future mistakes of this type: make
write_relcache_init_file Assert that all nailed relations get written to
the init file, and make load_relcache_init_file emit a WARNING if it takes
the "wrong number of nailed relations" exit path. Now that we remove the
init files during postmaster startup, that case should never occur in the
field, even if we are starting a minor-version update that added or removed
rels from the nailed set. So the warning shouldn't ever be seen by end
users, but it will show up in the regression tests if somebody breaks this
logic.
Back-patch to all supported branches, like the previous commit.
110 lines
3.2 KiB
C
110 lines
3.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* relcache.h
|
|
* Relation descriptor cache definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.69 2010/02/26 02:01:29 momjian Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef RELCACHE_H
|
|
#define RELCACHE_H
|
|
|
|
#include "access/tupdesc.h"
|
|
#include "nodes/bitmapset.h"
|
|
#include "nodes/pg_list.h"
|
|
|
|
|
|
typedef struct RelationData *Relation;
|
|
|
|
/* ----------------
|
|
* RelationPtr is used in the executor to support index scans
|
|
* where we have to keep track of several index relations in an
|
|
* array. -cim 9/10/89
|
|
* ----------------
|
|
*/
|
|
typedef Relation *RelationPtr;
|
|
|
|
/*
|
|
* Routines to open (lookup) and close a relcache entry
|
|
*/
|
|
extern Relation RelationIdGetRelation(Oid relationId);
|
|
extern void RelationClose(Relation relation);
|
|
|
|
/*
|
|
* Routines to compute/retrieve additional cached information
|
|
*/
|
|
extern List *RelationGetIndexList(Relation relation);
|
|
extern Oid RelationGetOidIndex(Relation relation);
|
|
extern List *RelationGetIndexExpressions(Relation relation);
|
|
extern List *RelationGetIndexPredicate(Relation relation);
|
|
extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation);
|
|
extern void RelationGetExclusionInfo(Relation indexRelation,
|
|
Oid **operators,
|
|
Oid **procs,
|
|
uint16 **strategies);
|
|
|
|
extern void RelationSetIndexList(Relation relation,
|
|
List *indexIds, Oid oidIndex);
|
|
|
|
extern void RelationInitIndexAccessInfo(Relation relation);
|
|
|
|
/*
|
|
* Routines for backend startup
|
|
*/
|
|
extern void RelationCacheInitialize(void);
|
|
extern void RelationCacheInitializePhase2(void);
|
|
extern void RelationCacheInitializePhase3(void);
|
|
|
|
/*
|
|
* Routine to create a relcache entry for an about-to-be-created relation
|
|
*/
|
|
extern Relation RelationBuildLocalRelation(const char *relname,
|
|
Oid relnamespace,
|
|
TupleDesc tupDesc,
|
|
Oid relid,
|
|
Oid reltablespace,
|
|
bool shared_relation,
|
|
bool mapped_relation);
|
|
|
|
/*
|
|
* Routine to manage assignment of new relfilenode to a relation
|
|
*/
|
|
extern void RelationSetNewRelfilenode(Relation relation,
|
|
TransactionId freezeXid);
|
|
|
|
/*
|
|
* Routines for flushing/rebuilding relcache entries in various scenarios
|
|
*/
|
|
extern void RelationForgetRelation(Oid rid);
|
|
|
|
extern void RelationCacheInvalidateEntry(Oid relationId);
|
|
|
|
extern void RelationCacheInvalidate(void);
|
|
|
|
extern void RelationCloseSmgrByOid(Oid relationId);
|
|
|
|
extern void AtEOXact_RelationCache(bool isCommit);
|
|
extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
|
|
SubTransactionId parentSubid);
|
|
|
|
/*
|
|
* Routines to help manage rebuilding of relcache init files
|
|
*/
|
|
extern bool RelationIdIsInInitFile(Oid relationId);
|
|
extern void RelationCacheInitFilePreInvalidate(void);
|
|
extern void RelationCacheInitFilePostInvalidate(void);
|
|
extern void RelationCacheInitFileRemove(void);
|
|
|
|
/* should be used only by relcache.c and catcache.c */
|
|
extern bool criticalRelcachesBuilt;
|
|
|
|
/* should be used only by relcache.c and postinit.c */
|
|
extern bool criticalSharedRelcachesBuilt;
|
|
|
|
#endif /* RELCACHE_H */
|