/*
- * CatalogCacheIdInvalidate
+ * CatCacheInvalidate
*
* Invalidate entries in the specified cache, given a hash value.
*
* 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 */
}
}
* 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.