diff options
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/inval.c | 29 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 39 |
2 files changed, 18 insertions, 50 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 8c1c33e7845..8933030a9dd 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -80,7 +80,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.68 2004/12/31 22:01:25 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.69 2005/01/10 20:02:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -414,17 +414,9 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) } else if (msg->id == SHAREDINVALRELCACHE_ID) { - /* - * If the message includes a valid relfilenode, we must ensure - * that smgr cache entry gets zapped. The relcache will handle - * this if called, otherwise we must do it directly. - */ if (msg->rc.dbId == MyDatabaseId || msg->rc.dbId == InvalidOid) { - if (OidIsValid(msg->rc.physId.relNode)) - RelationCacheInvalidateEntry(msg->rc.relId, &msg->rc.physId); - else - RelationCacheInvalidateEntry(msg->rc.relId, NULL); + RelationCacheInvalidateEntry(msg->rc.relId); for (i = 0; i < cache_callback_count; i++) { @@ -434,12 +426,17 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) (*ccitem->function) (ccitem->arg, msg->rc.relId); } } - else - { - /* might have smgr entry even if not in our database */ - if (OidIsValid(msg->rc.physId.relNode)) - smgrclosenode(msg->rc.physId); - } + /* + * If the message includes a valid relfilenode, we must ensure + * the smgr cache entry gets zapped. This might not have happened + * above since the relcache entry might not have existed or might + * have been associated with a different relfilenode. + * + * XXX there is no real good reason for rnode inval to be in the + * same message at all. FIXME in 8.1. + */ + if (OidIsValid(msg->rc.physId.relNode)) + smgrclosenode(msg->rc.physId); } else elog(FATAL, "unrecognized SI message id: %d", msg->id); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 8cc072de472..50ffb0f1b0e 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.214 2004/12/31 22:01:25 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.215 2005/01/10 20:02:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1659,11 +1659,7 @@ RelationClearRelation(Relation relation, bool rebuild) * ensures that the low-level file access state is updated after, say, * a vacuum truncation. */ - if (relation->rd_smgr) - { - smgrclose(relation->rd_smgr); - relation->rd_smgr = NULL; - } + RelationCloseSmgr(relation); /* * Never, never ever blow away a nailed-in system relation, because @@ -1857,16 +1853,7 @@ RelationForgetRelation(Oid rid) * * Any relcache entry matching the relid must be flushed. (Note: caller has * already determined that the relid belongs to our database or is a shared - * relation.) If rnode isn't NULL, we must also ensure that any smgr cache - * entry matching that rnode is flushed. - * - * Ordinarily, if rnode is supplied then it will match the relfilenode of - * the target relid. However, it's possible for rnode to be different if - * someone is engaged in a relfilenode change. In that case we want to - * make sure we clear the right cache entries. This has to be done here - * to keep things in sync between relcache and smgr cache --- we can't have - * someone flushing an smgr cache entry that a relcache entry still points - * to. + * relation.) * * We used to skip local relations, on the grounds that they could * not be targets of cross-backend SI update messages; but it seems @@ -1875,7 +1862,7 @@ RelationForgetRelation(Oid rid) * local and nonlocal relations. */ void -RelationCacheInvalidateEntry(Oid relationId, RelFileNode *rnode) +RelationCacheInvalidateEntry(Oid relationId) { Relation relation; @@ -1884,20 +1871,8 @@ RelationCacheInvalidateEntry(Oid relationId, RelFileNode *rnode) if (PointerIsValid(relation)) { relcacheInvalsReceived++; - if (rnode) - { - /* Need to be sure smgr is flushed, but don't do it twice */ - if (relation->rd_smgr == NULL || - !RelFileNodeEquals(*rnode, relation->rd_node)) - smgrclosenode(*rnode); - } RelationFlushRelation(relation); } - else - { - if (rnode) - smgrclosenode(*rnode); - } } /* @@ -1946,11 +1921,7 @@ RelationCacheInvalidate(void) relation = idhentry->reldesc; /* Must close all smgr references to avoid leaving dangling ptrs */ - if (relation->rd_smgr) - { - smgrclose(relation->rd_smgr); - relation->rd_smgr = NULL; - } + RelationCloseSmgr(relation); /* Ignore new relations, since they are never SI targets */ if (relation->rd_createSubid != InvalidSubTransactionId) |