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

Function InitCatalogCache

src/backend/utils/cache/syscache.c:1249–1300  ·  view source on GitHub ↗

* InitCatalogCache - initialize the caches * * Note that no database access is done here; we only allocate memory * and initialize the cache structure. Interrogation of the database * to complete initialization of a cache happens upon first use * of that cache. */

Source from the content-addressed store, hash-verified

1247 * of that cache.
1248 */
1249void
1250InitCatalogCache(void)
1251{
1252 int cacheId;
1253
1254 StaticAssertStmt(SysCacheSize == (int) lengthof(cacheinfo),
1255 "SysCacheSize does not match syscache.c's array");
1256
1257 Assert(!CacheInitialized);
1258
1259 SysCacheRelationOidSize = SysCacheSupportingRelOidSize = 0;
1260
1261 for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
1262 {
1263 SysCache[cacheId] = InitCatCache(cacheId,
1264 cacheinfo[cacheId].reloid,
1265 cacheinfo[cacheId].indoid,
1266 cacheinfo[cacheId].nkeys,
1267 cacheinfo[cacheId].key,
1268 cacheinfo[cacheId].nbuckets);
1269 if (!PointerIsValid(SysCache[cacheId]))
1270 elog(ERROR, "could not initialize cache %u (%d)",
1271 cacheinfo[cacheId].reloid, cacheId);
1272 /* Accumulate data for OID lists, too */
1273 SysCacheRelationOid[SysCacheRelationOidSize++] =
1274 cacheinfo[cacheId].reloid;
1275 SysCacheSupportingRelOid[SysCacheSupportingRelOidSize++] =
1276 cacheinfo[cacheId].reloid;
1277 SysCacheSupportingRelOid[SysCacheSupportingRelOidSize++] =
1278 cacheinfo[cacheId].indoid;
1279 /* see comments for RelationInvalidatesSnapshotsOnly */
1280 Assert(!RelationInvalidatesSnapshotsOnly(cacheinfo[cacheId].reloid));
1281 }
1282
1283 Assert(SysCacheRelationOidSize <= lengthof(SysCacheRelationOid));
1284 Assert(SysCacheSupportingRelOidSize <= lengthof(SysCacheSupportingRelOid));
1285
1286 /* Sort and de-dup OID arrays, so we can use binary search. */
1287 pg_qsort(SysCacheRelationOid, SysCacheRelationOidSize,
1288 sizeof(Oid), oid_compare);
1289 SysCacheRelationOidSize =
1290 qunique(SysCacheRelationOid, SysCacheRelationOidSize, sizeof(Oid),
1291 oid_compare);
1292
1293 pg_qsort(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
1294 sizeof(Oid), oid_compare);
1295 SysCacheSupportingRelOidSize =
1296 qunique(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
1297 sizeof(Oid), oid_compare);
1298
1299 CacheInitialized = true;
1300}
1301
1302/*
1303 * InitCatalogCachePhase2 - finish initializing the caches

Callers 2

InitPostgresFunction · 0.85

Calls 3

InitCatCacheFunction · 0.85
quniqueFunction · 0.85

Tested by

no test coverage detected