MCPcopy Create free account
hub / github.com/apache/cloudberry / RelationCacheInitializePhase3

Function RelationCacheInitializePhase3

src/backend/utils/cache/relcache.c:4195–4502  ·  view source on GitHub ↗

* RelationCacheInitializePhase3 * * This is called as soon as the catcache and transaction system * are functional and we have determined MyDatabaseId. At this point * we can actually read data from the database's system catalogs. * We first try to read pre-computed relcache entries from the local * relcache init file. If that's missing or broken, make phony entries * for the minim

Source from the content-addressed store, hash-verified

4193 * rewrite the cache files if needed.
4194 */
4195void
4196RelationCacheInitializePhase3(void)
4197{
4198 HASH_SEQ_STATUS status;
4199 RelIdCacheEnt *idhentry;
4200 MemoryContext oldcxt;
4201 bool needNewCacheFile = !criticalSharedRelcachesBuilt;
4202
4203 /*
4204 * Relation cache initialization or any sort of heap access is
4205 * dangerous before recovery is finished.
4206 */
4207 if (!EnableHotStandby && !IsBootstrapProcessingMode() && RecoveryInProgress())
4208 elog(ERROR, "relation cache initialization during recovery or non-bootstrap processes.");
4209
4210 /*
4211 * relation mapper needs initialized too
4212 */
4213 RelationMapInitializePhase3();
4214
4215 /*
4216 * switch to cache memory context
4217 */
4218 oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
4219
4220 /*
4221 * Try to load the local relcache cache file. If unsuccessful, bootstrap
4222 * the cache with pre-made descriptors for the critical "nailed-in" system
4223 * catalogs.
4224 */
4225 if (IsBootstrapProcessingMode() ||
4226 !load_relcache_init_file(false))
4227 {
4228 needNewCacheFile = true;
4229
4230 formrdesc("pg_class", RelationRelation_Rowtype_Id, false,
4231 Natts_pg_class, Desc_pg_class);
4232 formrdesc("pg_attribute", AttributeRelation_Rowtype_Id, false,
4233 Natts_pg_attribute, Desc_pg_attribute);
4234 formrdesc("pg_proc", ProcedureRelation_Rowtype_Id, false,
4235 Natts_pg_proc, Desc_pg_proc);
4236 formrdesc("pg_type", TypeRelation_Rowtype_Id, false,
4237 Natts_pg_type, Desc_pg_type);
4238
4239#define NUM_CRITICAL_LOCAL_RELS 4 /* fix if you change list above */
4240 }
4241
4242 MemoryContextSwitchTo(oldcxt);
4243
4244 /* In bootstrap mode, the faked-up formrdesc info is all we'll have */
4245 if (IsBootstrapProcessingMode())
4246 return;
4247
4248 /*
4249 * If we didn't get the critical system indexes loaded into relcache, do
4250 * so now. These are critical because the catcache and/or opclass cache
4251 * depend on them for fetches done during relcache load. Thus, we have an
4252 * infinite-recursion problem. We can break the recursion by doing

Callers 2

InitPostgresFunction · 0.85

Calls 15

RecoveryInProgressFunction · 0.85
MemoryContextSwitchToFunction · 0.85
load_relcache_init_fileFunction · 0.85
formrdescFunction · 0.85
load_critical_indexFunction · 0.85
hash_seq_initFunction · 0.85
hash_seq_searchFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
RelationParseRelOptionsFunction · 0.85

Tested by

no test coverage detected