diff options
Diffstat (limited to 'src/backend/utils/cache/catcache.c')
-rw-r--r-- | src/backend/utils/cache/catcache.c | 92 |
1 files changed, 39 insertions, 53 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 954b435bffa..db4599ec4a3 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -425,7 +425,7 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl) /* - * CatalogCacheIdInvalidate + * CatCacheInvalidate * * Invalidate entries in the specified cache, given a hash value. * @@ -443,71 +443,57 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl) * This routine is only quasi-public: it should only be used by inval.c. */ void -CatalogCacheIdInvalidate(int cacheId, uint32 hashValue) +CatCacheInvalidate(CatCache *cache, uint32 hashValue) { - slist_iter cache_iter; + Index hashIndex; + dlist_mutable_iter iter; - CACHE1_elog(DEBUG2, "CatalogCacheIdInvalidate: called"); + CACHE1_elog(DEBUG2, "CatCacheInvalidate: called"); /* - * inspect caches to find the proper cache + * We don't bother to check whether the cache has finished initialization + * yet; if not, there will be no entries in it so no problem. */ - slist_foreach(cache_iter, &CacheHdr->ch_caches) - { - CatCache *ccp = slist_container(CatCache, cc_next, cache_iter.cur); - Index hashIndex; - dlist_mutable_iter iter; - - if (cacheId != ccp->id) - continue; - /* - * We don't bother to check whether the cache has finished - * initialization yet; if not, there will be no entries in it so no - * problem. - */ + /* + * Invalidate *all* CatCLists in this cache; it's too hard to tell which + * searches might still be correct, so just zap 'em all. + */ + dlist_foreach_modify(iter, &cache->cc_lists) + { + CatCList *cl = dlist_container(CatCList, cache_elem, iter.cur); - /* - * Invalidate *all* CatCLists in this cache; it's too hard to tell - * which searches might still be correct, so just zap 'em all. - */ - dlist_foreach_modify(iter, &ccp->cc_lists) - { - CatCList *cl = dlist_container(CatCList, cache_elem, iter.cur); + if (cl->refcount > 0) + cl->dead = true; + else + CatCacheRemoveCList(cache, cl); + } - if (cl->refcount > 0) - cl->dead = true; - else - CatCacheRemoveCList(ccp, cl); - } + /* + * inspect the proper hash bucket for tuple matches + */ + hashIndex = HASH_INDEX(hashValue, cache->cc_nbuckets); + dlist_foreach_modify(iter, &cache->cc_bucket[hashIndex]) + { + CatCTup *ct = dlist_container(CatCTup, cache_elem, iter.cur); - /* - * inspect the proper hash bucket for tuple matches - */ - hashIndex = HASH_INDEX(hashValue, ccp->cc_nbuckets); - dlist_foreach_modify(iter, &ccp->cc_bucket[hashIndex]) + if (hashValue == ct->hash_value) { - CatCTup *ct = dlist_container(CatCTup, cache_elem, iter.cur); - - if (hashValue == ct->hash_value) + if (ct->refcount > 0 || + (ct->c_list && ct->c_list->refcount > 0)) { - if (ct->refcount > 0 || - (ct->c_list && ct->c_list->refcount > 0)) - { - ct->dead = true; - /* list, if any, was marked dead above */ - Assert(ct->c_list == NULL || ct->c_list->dead); - } - else - CatCacheRemoveCTup(ccp, ct); - CACHE1_elog(DEBUG2, "CatalogCacheIdInvalidate: invalidated"); + ct->dead = true; + /* list, if any, was marked dead above */ + Assert(ct->c_list == NULL || ct->c_list->dead); + } + else + CatCacheRemoveCTup(cache, ct); + CACHE1_elog(DEBUG2, "CatCacheInvalidate: invalidated"); #ifdef CATCACHE_STATS - ccp->cc_invals++; + cache->cc_invals++; #endif - /* could be multiple matches, so keep looking! */ - } + /* could be multiple matches, so keep looking! */ } - break; /* need only search this one cache */ } } @@ -1815,7 +1801,7 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys) * the specified relation, find all catcaches it could be in, compute the * correct hash value for each such catcache, and call the specified * function to record the cache id and hash value in inval.c's lists. - * CatalogCacheIdInvalidate will be called later, if appropriate, + * SysCacheInvalidate will be called later, if appropriate, * using the recorded information. * * For an insert or delete, tuple is the target tuple and newtuple is NULL. |