8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
15
15
/*
16
16
* INTERFACE ROUTINES
17
- * RelationCacheInitialize - initialize relcache
17
+ * RelationCacheInitialize - initialize relcache (to empty)
18
18
* RelationCacheInitializePhase2 - finish initializing relcache
19
19
* RelationIdGetRelation - get a reldesc by relation id
20
20
* RelationIdCacheGetRelation - get a cached reldesc by relid
@@ -102,12 +102,6 @@ static HTAB *RelationIdCache;
102
102
*/
103
103
bool criticalRelcachesBuilt = false;
104
104
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
-
111
105
/*
112
106
* This counter counts relcache inval events received since backend startup
113
107
* (but only for rels that are actually in cache). Presently, we use it only
@@ -1162,14 +1156,14 @@ LookupOpclassInfo(Oid operatorClassOid,
1162
1156
* formrdesc
1163
1157
*
1164
1158
* 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.
1166
1160
* The relation descriptor is built just from the supplied parameters,
1167
1161
* without actually looking at any system table entries. We cheat
1168
1162
* quite a lot since we only need to work for a few basic system
1169
1163
* catalogs.
1170
1164
*
1171
1165
* formrdesc is currently used for: pg_class, pg_attribute, pg_proc,
1172
- * and pg_type (see RelationCacheInitialize ).
1166
+ * and pg_type (see RelationCacheInitializePhase2 ).
1173
1167
*
1174
1168
* Note that these catalogs can't have constraints (except attnotnull),
1175
1169
* default values, rules, or triggers, since we don't cope with any of that.
@@ -2026,7 +2020,7 @@ RelationBuildLocalRelation(const char *relname,
2026
2020
/*
2027
2021
* check for creation of a rel that must be nailed in cache.
2028
2022
*
2029
- * XXX this list had better match RelationCacheInitialize 's list.
2023
+ * XXX this list had better match RelationCacheInitializePhase2 's list.
2030
2024
*/
2031
2025
switch (relid )
2032
2026
{
@@ -2180,7 +2174,7 @@ RelationCacheInitialize(void)
2180
2174
oldcxt = MemoryContextSwitchTo (CacheMemoryContext );
2181
2175
2182
2176
/*
2183
- * create hashtables that index the relcache
2177
+ * create hashtable that indexes the relcache
2184
2178
*/
2185
2179
MemSet (& ctl , 0 , sizeof (ctl ));
2186
2180
ctl .keysize = sizeof (Oid );
@@ -2211,6 +2205,7 @@ RelationCacheInitializePhase2(void)
2211
2205
HASH_SEQ_STATUS status ;
2212
2206
RelIdCacheEnt * idhentry ;
2213
2207
MemoryContext oldcxt ;
2208
+ bool needNewCacheFile = false;
2214
2209
2215
2210
/*
2216
2211
* switch to cache memory context
@@ -2225,6 +2220,8 @@ RelationCacheInitializePhase2(void)
2225
2220
if (IsBootstrapProcessingMode () ||
2226
2221
!load_relcache_init_file ())
2227
2222
{
2223
+ needNewCacheFile = true;
2224
+
2228
2225
formrdesc ("pg_class" , PG_CLASS_RELTYPE_OID ,
2229
2226
true, Natts_pg_class , Desc_pg_class );
2230
2227
formrdesc ("pg_attribute" , PG_ATTRIBUTE_RELTYPE_OID ,
@@ -2909,7 +2906,7 @@ RelationGetIndexPredicate(Relation relation)
2909
2906
* load_relcache_init_file -- attempt to load cache from the init file
2910
2907
*
2911
2908
* 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.
2913
2910
*
2914
2911
* NOTE: we assume we are already switched into CacheMemoryContext.
2915
2912
*/
@@ -2932,10 +2929,7 @@ load_relcache_init_file(void)
2932
2929
2933
2930
fp = AllocateFile (initfilename , PG_BINARY_R );
2934
2931
if (fp == NULL )
2935
- {
2936
- needNewCacheFile = true;
2937
2932
return false;
2938
- }
2939
2933
2940
2934
/*
2941
2935
* Read the index relcache entries from the file. Note we will not enter
@@ -3199,7 +3193,6 @@ load_relcache_init_file(void)
3199
3193
pfree (rels );
3200
3194
FreeFile (fp );
3201
3195
3202
- needNewCacheFile = true;
3203
3196
return false;
3204
3197
}
3205
3198
0 commit comments