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

Function CatalogCacheInitializeCache

src/backend/utils/cache/catcache.c:923–1021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921#endif
922
923static void
924CatalogCacheInitializeCache(CatCache *cache)
925{
926 Relation relation;
927 MemoryContext oldcxt;
928 TupleDesc tupdesc;
929 int i;
930
931 CatalogCacheInitializeCache_DEBUG1;
932
933 relation = table_open(cache->cc_reloid, AccessShareLock);
934
935 /*
936 * switch to the cache context so our allocations do not vanish at the end
937 * of a transaction
938 */
939 Assert(CacheMemoryContext != NULL);
940
941 oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
942
943 /*
944 * copy the relcache's tuple descriptor to permanent cache storage
945 */
946 tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
947
948 /*
949 * save the relation's name and relisshared flag, too (cc_relname is used
950 * only for debugging purposes)
951 */
952 cache->cc_relname = pstrdup(RelationGetRelationName(relation));
953 cache->cc_relisshared = RelationGetForm(relation)->relisshared;
954
955 /*
956 * return to the caller's memory context and close the rel
957 */
958 MemoryContextSwitchTo(oldcxt);
959
960 table_close(relation, AccessShareLock);
961
962 CACHE_elog(DEBUG2, "CatalogCacheInitializeCache: %s, %d keys",
963 cache->cc_relname, cache->cc_nkeys);
964
965 /*
966 * initialize cache's key information
967 */
968 for (i = 0; i < cache->cc_nkeys; ++i)
969 {
970 Oid keytype;
971 RegProcedure eqfunc;
972
973 CatalogCacheInitializeCache_DEBUG2;
974
975 if (cache->cc_keyno[i] > 0)
976 {
977 Form_pg_attribute attr = TupleDescAttr(tupdesc,
978 cache->cc_keyno[i] - 1);
979
980 keytype = attr->atttypid;

Callers 5

InitCatCachePhase2Function · 0.85
SearchCatCacheInternalFunction · 0.85
GetCatCacheHashValueFunction · 0.85
SearchCatCacheListFunction · 0.85

Calls 7

table_openFunction · 0.85
MemoryContextSwitchToFunction · 0.85
table_closeFunction · 0.85
GetCCHashEqFuncsFunction · 0.85
fmgr_info_cxtFunction · 0.85
pstrdupFunction · 0.50

Tested by

no test coverage detected