mirror of
https://github.com/postgres/postgres.git
synced 2026-03-31 23:07:04 -04:00
Improve 'pg_internal.init' relcache entry preload mechanism so that it is safe to use for all system catalogs, and arrange to preload a realistic set of system-catalog entries instead of only the three nailed-in-cache indexes that were formerly loaded this way. Fix mechanism for deleting out-of-date pg_internal.init files: this must be synchronized with transaction commit, not just done at random times within transactions. Drive it off relcache invalidation mechanism so that no special-case tests are needed. Cache additional information in relcache entries for indexes (their pg_index tuples and index-operator OIDs) to eliminate repeated lookups. Also cache index opclass info at the per-opclass level to avoid repeated lookups during relcache load. Generalize 'systable scan' utilities originally developed by Hiroshi, move them into genam.c, use in a number of places where there was formerly ugly code for choosing either heap or index scan. In particular this allows simplification of the logic that prevents infinite recursion between syscache and relcache during startup: we can easily switch to heapscans in relcache.c when and where needed to avoid recursion, so IndexScanOK becomes simpler and does not need any expensive initialization. Eliminate useless opening of a heapscan data structure while doing an indexscan (this saves an mdnblocks call and thus at least one kernel call).
80 lines
2.2 KiB
C
80 lines
2.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* relcache.h
|
|
* Relation descriptor cache definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $Id: relcache.h,v 1.30 2002/02/19 20:11:20 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef RELCACHE_H
|
|
#define RELCACHE_H
|
|
|
|
#include "utils/rel.h"
|
|
|
|
/*
|
|
* relation lookup routines
|
|
*/
|
|
extern Relation RelationIdGetRelation(Oid relationId);
|
|
extern Relation RelationNameGetRelation(const char *relationName);
|
|
extern Relation RelationNodeCacheGetRelation(RelFileNode rnode);
|
|
|
|
/* finds an existing cache entry, but won't make a new one */
|
|
extern Relation RelationIdCacheGetRelation(Oid relationId);
|
|
|
|
extern void RelationClose(Relation relation);
|
|
|
|
/*
|
|
* Routines to compute/retrieve additional cached information
|
|
*/
|
|
extern List *RelationGetIndexList(Relation relation);
|
|
|
|
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,
|
|
TupleDesc tupDesc,
|
|
Oid relid, Oid dbid,
|
|
bool nailit);
|
|
|
|
/*
|
|
* Routines for flushing/rebuilding relcache entries in various scenarios
|
|
*/
|
|
extern void RelationForgetRelation(Oid rid);
|
|
|
|
extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId);
|
|
|
|
extern void RelationCacheInvalidate(void);
|
|
|
|
extern void RelationPurgeLocalRelation(bool xactComitted);
|
|
|
|
extern void RelationCacheAbort(void);
|
|
|
|
/*
|
|
* Routines to help manage rebuilding of relcache init file
|
|
*/
|
|
extern bool RelationIdIsInInitFile(Oid relationId);
|
|
extern void RelationCacheInitFileInvalidate(bool beforeSend);
|
|
|
|
/* XLOG support */
|
|
extern void CreateDummyCaches(void);
|
|
extern void DestroyDummyCaches(void);
|
|
|
|
|
|
/* should be used only by relcache.c and catcache.c */
|
|
extern bool criticalRelcachesBuilt;
|
|
|
|
#endif /* RELCACHE_H */
|