Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cbc0539

Browse files
committed
Further minor simplification of relcache startup: don't need a static
needNewCacheFile flag anymore, it can just be local in RelationCacheInitializePhase2.
1 parent 069ad5f commit cbc0539

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/backend/utils/cache/relcache.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.240 2006/05/04 18:51:35 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.241 2006/05/06 15:51:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
/*
1616
* INTERFACE ROUTINES
17-
* RelationCacheInitialize - initialize relcache
17+
* RelationCacheInitialize - initialize relcache (to empty)
1818
* RelationCacheInitializePhase2 - finish initializing relcache
1919
* RelationIdGetRelation - get a reldesc by relation id
2020
* RelationIdCacheGetRelation - get a cached reldesc by relid
@@ -102,12 +102,6 @@ static HTAB *RelationIdCache;
102102
*/
103103
bool criticalRelcachesBuilt = false;
104104

105-
/*
106-
* This flag is set if we discover that we need to write a new relcache
107-
* cache file at the end of startup.
108-
*/
109-
static bool needNewCacheFile = false;
110-
111105
/*
112106
* This counter counts relcache inval events received since backend startup
113107
* (but only for rels that are actually in cache). Presently, we use it only
@@ -1162,14 +1156,14 @@ LookupOpclassInfo(Oid operatorClassOid,
11621156
* formrdesc
11631157
*
11641158
* This is a special cut-down version of RelationBuildDesc()
1165-
* used by RelationCacheInitialize() in initializing the relcache.
1159+
* used by RelationCacheInitializePhase2() in initializing the relcache.
11661160
* The relation descriptor is built just from the supplied parameters,
11671161
* without actually looking at any system table entries. We cheat
11681162
* quite a lot since we only need to work for a few basic system
11691163
* catalogs.
11701164
*
11711165
* formrdesc is currently used for: pg_class, pg_attribute, pg_proc,
1172-
* and pg_type (see RelationCacheInitialize).
1166+
* and pg_type (see RelationCacheInitializePhase2).
11731167
*
11741168
* Note that these catalogs can't have constraints (except attnotnull),
11751169
* default values, rules, or triggers, since we don't cope with any of that.
@@ -2026,7 +2020,7 @@ RelationBuildLocalRelation(const char *relname,
20262020
/*
20272021
* check for creation of a rel that must be nailed in cache.
20282022
*
2029-
* XXX this list had better match RelationCacheInitialize's list.
2023+
* XXX this list had better match RelationCacheInitializePhase2's list.
20302024
*/
20312025
switch (relid)
20322026
{
@@ -2180,7 +2174,7 @@ RelationCacheInitialize(void)
21802174
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
21812175

21822176
/*
2183-
* create hashtables that index the relcache
2177+
* create hashtable that indexes the relcache
21842178
*/
21852179
MemSet(&ctl, 0, sizeof(ctl));
21862180
ctl.keysize = sizeof(Oid);
@@ -2211,6 +2205,7 @@ RelationCacheInitializePhase2(void)
22112205
HASH_SEQ_STATUS status;
22122206
RelIdCacheEnt *idhentry;
22132207
MemoryContext oldcxt;
2208+
bool needNewCacheFile = false;
22142209

22152210
/*
22162211
* switch to cache memory context
@@ -2225,6 +2220,8 @@ RelationCacheInitializePhase2(void)
22252220
if (IsBootstrapProcessingMode() ||
22262221
!load_relcache_init_file())
22272222
{
2223+
needNewCacheFile = true;
2224+
22282225
formrdesc("pg_class", PG_CLASS_RELTYPE_OID,
22292226
true, Natts_pg_class, Desc_pg_class);
22302227
formrdesc("pg_attribute", PG_ATTRIBUTE_RELTYPE_OID,
@@ -2909,7 +2906,7 @@ RelationGetIndexPredicate(Relation relation)
29092906
* load_relcache_init_file -- attempt to load cache from the init file
29102907
*
29112908
* If successful, return TRUE and set criticalRelcachesBuilt to true.
2912-
* If not successful, return FALSE and set needNewCacheFile to true.
2909+
* If not successful, return FALSE.
29132910
*
29142911
* NOTE: we assume we are already switched into CacheMemoryContext.
29152912
*/
@@ -2932,10 +2929,7 @@ load_relcache_init_file(void)
29322929

29332930
fp = AllocateFile(initfilename, PG_BINARY_R);
29342931
if (fp == NULL)
2935-
{
2936-
needNewCacheFile = true;
29372932
return false;
2938-
}
29392933

29402934
/*
29412935
* Read the index relcache entries from the file. Note we will not enter
@@ -3199,7 +3193,6 @@ load_relcache_init_file(void)
31993193
pfree(rels);
32003194
FreeFile(fp);
32013195

3202-
needNewCacheFile = true;
32033196
return false;
32043197
}
32053198

0 commit comments

Comments
 (0)