mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 23:33:26 +02:00
Further minor simplification of relcache startup: don't need a static
needNewCacheFile flag anymore, it can just be local in RelationCacheInitializePhase2.
This commit is contained in:
parent
069ad5fcc3
commit
cbc0539c2a
27
src/backend/utils/cache/relcache.c
vendored
27
src/backend/utils/cache/relcache.c
vendored
@ -8,13 +8,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.240 2006/05/04 18:51:35 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.241 2006/05/06 15:51:07 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* RelationCacheInitialize - initialize relcache
|
* RelationCacheInitialize - initialize relcache (to empty)
|
||||||
* RelationCacheInitializePhase2 - finish initializing relcache
|
* RelationCacheInitializePhase2 - finish initializing relcache
|
||||||
* RelationIdGetRelation - get a reldesc by relation id
|
* RelationIdGetRelation - get a reldesc by relation id
|
||||||
* RelationIdCacheGetRelation - get a cached reldesc by relid
|
* RelationIdCacheGetRelation - get a cached reldesc by relid
|
||||||
@ -102,12 +102,6 @@ static HTAB *RelationIdCache;
|
|||||||
*/
|
*/
|
||||||
bool criticalRelcachesBuilt = false;
|
bool criticalRelcachesBuilt = false;
|
||||||
|
|
||||||
/*
|
|
||||||
* This flag is set if we discover that we need to write a new relcache
|
|
||||||
* cache file at the end of startup.
|
|
||||||
*/
|
|
||||||
static bool needNewCacheFile = false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This counter counts relcache inval events received since backend startup
|
* This counter counts relcache inval events received since backend startup
|
||||||
* (but only for rels that are actually in cache). Presently, we use it only
|
* (but only for rels that are actually in cache). Presently, we use it only
|
||||||
@ -1162,14 +1156,14 @@ LookupOpclassInfo(Oid operatorClassOid,
|
|||||||
* formrdesc
|
* formrdesc
|
||||||
*
|
*
|
||||||
* This is a special cut-down version of RelationBuildDesc()
|
* This is a special cut-down version of RelationBuildDesc()
|
||||||
* used by RelationCacheInitialize() in initializing the relcache.
|
* used by RelationCacheInitializePhase2() in initializing the relcache.
|
||||||
* The relation descriptor is built just from the supplied parameters,
|
* The relation descriptor is built just from the supplied parameters,
|
||||||
* without actually looking at any system table entries. We cheat
|
* without actually looking at any system table entries. We cheat
|
||||||
* quite a lot since we only need to work for a few basic system
|
* quite a lot since we only need to work for a few basic system
|
||||||
* catalogs.
|
* catalogs.
|
||||||
*
|
*
|
||||||
* formrdesc is currently used for: pg_class, pg_attribute, pg_proc,
|
* formrdesc is currently used for: pg_class, pg_attribute, pg_proc,
|
||||||
* and pg_type (see RelationCacheInitialize).
|
* and pg_type (see RelationCacheInitializePhase2).
|
||||||
*
|
*
|
||||||
* Note that these catalogs can't have constraints (except attnotnull),
|
* Note that these catalogs can't have constraints (except attnotnull),
|
||||||
* default values, rules, or triggers, since we don't cope with any of that.
|
* default values, rules, or triggers, since we don't cope with any of that.
|
||||||
@ -2026,7 +2020,7 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
/*
|
/*
|
||||||
* check for creation of a rel that must be nailed in cache.
|
* check for creation of a rel that must be nailed in cache.
|
||||||
*
|
*
|
||||||
* XXX this list had better match RelationCacheInitialize's list.
|
* XXX this list had better match RelationCacheInitializePhase2's list.
|
||||||
*/
|
*/
|
||||||
switch (relid)
|
switch (relid)
|
||||||
{
|
{
|
||||||
@ -2180,7 +2174,7 @@ RelationCacheInitialize(void)
|
|||||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create hashtables that index the relcache
|
* create hashtable that indexes the relcache
|
||||||
*/
|
*/
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
@ -2211,6 +2205,7 @@ RelationCacheInitializePhase2(void)
|
|||||||
HASH_SEQ_STATUS status;
|
HASH_SEQ_STATUS status;
|
||||||
RelIdCacheEnt *idhentry;
|
RelIdCacheEnt *idhentry;
|
||||||
MemoryContext oldcxt;
|
MemoryContext oldcxt;
|
||||||
|
bool needNewCacheFile = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* switch to cache memory context
|
* switch to cache memory context
|
||||||
@ -2225,6 +2220,8 @@ RelationCacheInitializePhase2(void)
|
|||||||
if (IsBootstrapProcessingMode() ||
|
if (IsBootstrapProcessingMode() ||
|
||||||
!load_relcache_init_file())
|
!load_relcache_init_file())
|
||||||
{
|
{
|
||||||
|
needNewCacheFile = true;
|
||||||
|
|
||||||
formrdesc("pg_class", PG_CLASS_RELTYPE_OID,
|
formrdesc("pg_class", PG_CLASS_RELTYPE_OID,
|
||||||
true, Natts_pg_class, Desc_pg_class);
|
true, Natts_pg_class, Desc_pg_class);
|
||||||
formrdesc("pg_attribute", PG_ATTRIBUTE_RELTYPE_OID,
|
formrdesc("pg_attribute", PG_ATTRIBUTE_RELTYPE_OID,
|
||||||
@ -2909,7 +2906,7 @@ RelationGetIndexPredicate(Relation relation)
|
|||||||
* load_relcache_init_file -- attempt to load cache from the init file
|
* load_relcache_init_file -- attempt to load cache from the init file
|
||||||
*
|
*
|
||||||
* If successful, return TRUE and set criticalRelcachesBuilt to true.
|
* If successful, return TRUE and set criticalRelcachesBuilt to true.
|
||||||
* If not successful, return FALSE and set needNewCacheFile to true.
|
* If not successful, return FALSE.
|
||||||
*
|
*
|
||||||
* NOTE: we assume we are already switched into CacheMemoryContext.
|
* NOTE: we assume we are already switched into CacheMemoryContext.
|
||||||
*/
|
*/
|
||||||
@ -2932,10 +2929,7 @@ load_relcache_init_file(void)
|
|||||||
|
|
||||||
fp = AllocateFile(initfilename, PG_BINARY_R);
|
fp = AllocateFile(initfilename, PG_BINARY_R);
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
|
||||||
needNewCacheFile = true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the index relcache entries from the file. Note we will not enter
|
* Read the index relcache entries from the file. Note we will not enter
|
||||||
@ -3199,7 +3193,6 @@ read_failed:
|
|||||||
pfree(rels);
|
pfree(rels);
|
||||||
FreeFile(fp);
|
FreeFile(fp);
|
||||||
|
|
||||||
needNewCacheFile = true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user