/* * InvalidateSystemCaches * * This blows away all tuples in the system catalog caches and * all the cached relation descriptors and smgr cache entries. * Relation descriptors that have positive refcounts are then rebuilt. * * We call this when we see a shared-inval-queue overflow signal, * since that tells us we've lost some shared-inval messages and hence * don't know what needs to be invalidated. */ static void InvalidateSystemCaches(void) { int i; ResetCatalogCaches(); RelationCacheInvalidate(); /* gets smgr cache too */ for (i = 0; i < cache_callback_count; i++) { struct CACHECALLBACK *ccitem = cache_callback_list + i; (*ccitem->function) (ccitem->arg, InvalidOid); } }
/* * InvalidateSystemCaches * * This blows away all tuples in the system catalog caches and * all the cached relation descriptors and smgr cache entries. * Relation descriptors that have positive refcounts are then rebuilt. * * We call this when we see a shared-inval-queue overflow signal, * since that tells us we've lost some shared-inval messages and hence * don't know what needs to be invalidated. */ static void InvalidateSystemCaches(void) { int i; ResetCatalogCaches(); RelationCacheInvalidate(); /* gets smgr and relmap too */ for (i = 0; i < syscache_callback_count; i++) { struct SYSCACHECALLBACK *ccitem = syscache_callback_list + i; (*ccitem->function) (ccitem->arg, ccitem->id, 0); } for (i = 0; i < relcache_callback_count; i++) { struct RELCACHECALLBACK *ccitem = relcache_callback_list + i; (*ccitem->function) (ccitem->arg, InvalidOid); } }
/* * LocalExecuteInvalidationMessage * * Process a single invalidation message (which could be of any type). * Only the local caches are flushed; this does not transmit the message * to other backends. */ void LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) { if (msg->id >= 0) { if (msg->cc.dbId == MyDatabaseId || msg->cc.dbId == InvalidOid) { InvalidateCatalogSnapshot(); SysCacheInvalidate(msg->cc.id, msg->cc.hashValue); CallSyscacheCallbacks(msg->cc.id, msg->cc.hashValue); } } else if (msg->id == SHAREDINVALCATALOG_ID) { if (msg->cat.dbId == MyDatabaseId || msg->cat.dbId == InvalidOid) { InvalidateCatalogSnapshot(); CatalogCacheFlushCatalog(msg->cat.catId); /* CatalogCacheFlushCatalog calls CallSyscacheCallbacks as needed */ } } else if (msg->id == SHAREDINVALRELCACHE_ID) { if (msg->rc.dbId == MyDatabaseId || msg->rc.dbId == InvalidOid) { int i; if (msg->rc.relId == InvalidOid) RelationCacheInvalidate(); else RelationCacheInvalidateEntry(msg->rc.relId); for (i = 0; i < relcache_callback_count; i++) { struct RELCACHECALLBACK *ccitem = relcache_callback_list + i; ccitem->function(ccitem->arg, msg->rc.relId); } } } else if (msg->id == SHAREDINVALSMGR_ID) { /* * We could have smgr entries for relations of other databases, so no * short-circuit test is possible here. */ RelFileNodeBackend rnode; rnode.node = msg->sm.rnode; rnode.backend = (msg->sm.backend_hi << 16) | (int) msg->sm.backend_lo; smgrclosenode(rnode); } else if (msg->id == SHAREDINVALRELMAP_ID) { /* We only care about our own database and shared catalogs */ if (msg->rm.dbId == InvalidOid) RelationMapInvalidate(true); else if (msg->rm.dbId == MyDatabaseId) RelationMapInvalidate(false); } else if (msg->id == SHAREDINVALSNAPSHOT_ID) { /* We only care about our own database and shared catalogs */ if (msg->rm.dbId == InvalidOid) InvalidateCatalogSnapshot(); else if (msg->rm.dbId == MyDatabaseId) InvalidateCatalogSnapshot(); } else elog(FATAL, "unrecognized SI message ID: %d", msg->id); }