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

Function ResetCatalogCache

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

* ResetCatalogCache * * Reset one catalog cache to empty. * * This is not very efficient if the target cache is nearly empty. * However, it shouldn't need to be efficient; we don't invoke it often. */

Source from the content-addressed store, hash-verified

640 * However, it shouldn't need to be efficient; we don't invoke it often.
641 */
642static void
643ResetCatalogCache(CatCache *cache)
644{
645 dlist_mutable_iter iter;
646 int i;
647
648 /* Remove each list in this cache, or at least mark it dead */
649 dlist_foreach_modify(iter, &cache->cc_lists)
650 {
651 CatCList *cl = dlist_container(CatCList, cache_elem, iter.cur);
652
653 if (cl->refcount > 0)
654 cl->dead = true;
655 else
656 CatCacheRemoveCList(cache, cl);
657 }
658
659 /* Remove each tuple in this cache, or at least mark it dead */
660 for (i = 0; i < cache->cc_nbuckets; i++)
661 {
662 dlist_head *bucket = &cache->cc_bucket[i];
663
664 dlist_foreach_modify(iter, bucket)
665 {
666 CatCTup *ct = dlist_container(CatCTup, cache_elem, iter.cur);
667
668 if (ct->refcount > 0 ||
669 (ct->c_list && ct->c_list->refcount > 0))
670 {
671 ct->dead = true;
672 /* list, if any, was marked dead above */
673 Assert(ct->c_list == NULL || ct->c_list->dead);
674 }
675 else
676 CatCacheRemoveCTup(cache, ct);
677#ifdef CATCACHE_STATS
678 cache->cc_invals++;
679#endif
680 }
681 }
682}
683
684/*
685 * ResetCatalogCaches

Callers 2

ResetCatalogCachesFunction · 0.85
CatalogCacheFlushCatalogFunction · 0.85

Calls 2

CatCacheRemoveCListFunction · 0.85
CatCacheRemoveCTupFunction · 0.85

Tested by

no test coverage detected