* 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. */
| 640 | * However, it shouldn't need to be efficient; we don't invoke it often. |
| 641 | */ |
| 642 | static void |
| 643 | ResetCatalogCache(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 |
no test coverage detected