* CatCacheRemoveCTup * * Unlink and delete the given cache entry * * NB: if it is a member of a CatCList, the CatCList is deleted too. * Both the cache entry and the list had better have zero refcount. */
| 455 | * Both the cache entry and the list had better have zero refcount. |
| 456 | */ |
| 457 | static void |
| 458 | CatCacheRemoveCTup(CatCache *cache, CatCTup *ct) |
| 459 | { |
| 460 | Assert(ct->refcount == 0); |
| 461 | Assert(ct->my_cache == cache); |
| 462 | |
| 463 | if (ct->c_list) |
| 464 | { |
| 465 | /* |
| 466 | * The cleanest way to handle this is to call CatCacheRemoveCList, |
| 467 | * which will recurse back to me, and the recursive call will do the |
| 468 | * work. Set the "dead" flag to make sure it does recurse. |
| 469 | */ |
| 470 | ct->dead = true; |
| 471 | CatCacheRemoveCList(cache, ct->c_list); |
| 472 | return; /* nothing left to do */ |
| 473 | } |
| 474 | |
| 475 | /* delink from linked list */ |
| 476 | dlist_delete(&ct->cache_elem); |
| 477 | |
| 478 | /* |
| 479 | * Free keys when we're dealing with a negative entry, normal entries just |
| 480 | * point into tuple, allocated together with the CatCTup. |
| 481 | */ |
| 482 | if (ct->negative) |
| 483 | CatCacheFreeKeys(cache->cc_tupdesc, cache->cc_nkeys, |
| 484 | cache->cc_keyno, ct->keys); |
| 485 | |
| 486 | pfree(ct); |
| 487 | |
| 488 | --cache->cc_ntup; |
| 489 | --CacheHdr->ch_ntup; |
| 490 | } |
| 491 | |
| 492 | /* |
| 493 | * CatCacheRemoveCList |
no test coverage detected