diff options
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/inval.c | 20 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 34 |
2 files changed, 38 insertions, 16 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 7a67f4a85e8..14904839222 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.98 2010/02/26 02:01:11 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.99 2010/08/13 20:10:52 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -319,7 +319,8 @@ AddCatcacheInvalidationMessage(InvalidationListHeader *hdr, { SharedInvalidationMessage msg; - msg.cc.id = (int16) id; + Assert(id < CHAR_MAX); + msg.cc.id = (int8) id; msg.cc.tuplePtr = *tuplePtr; msg.cc.dbId = dbId; msg.cc.hashValue = hashValue; @@ -513,7 +514,10 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) * We could have smgr entries for relations of other databases, so no * short-circuit test is possible here. */ - smgrclosenode(msg->sm.rnode); + 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) { @@ -1163,14 +1167,20 @@ CacheInvalidateRelcacheByRelid(Oid relid) * in commit/abort WAL entries. Instead, calls to CacheInvalidateSmgr() * should happen in low-level smgr.c routines, which are executed while * replaying WAL as well as when creating it. + * + * Note: In order to avoid bloating SharedInvalidationMessage, we store only + * three bytes of the backend ID using what would otherwise be padding space. + * Thus, the maximum possible backend ID is 2^23-1. */ void -CacheInvalidateSmgr(RelFileNode rnode) +CacheInvalidateSmgr(RelFileNodeBackend rnode) { SharedInvalidationMessage msg; msg.sm.id = SHAREDINVALSMGR_ID; - msg.sm.rnode = rnode; + msg.sm.backend_hi = rnode.backend >> 16; + msg.sm.backend_lo = rnode.backend & 0xffff; + msg.sm.rnode = rnode.node; SendSharedInvalidMessages(&msg, 1); } diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index f4304bce728..166beb25b15 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.311 2010/07/06 19:18:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.312 2010/08/13 20:10:52 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -858,10 +858,20 @@ RelationBuildDesc(Oid targetRelId, bool insertIt) relation->rd_createSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; relation->rd_istemp = relation->rd_rel->relistemp; - if (relation->rd_istemp) - relation->rd_islocaltemp = isTempOrToastNamespace(relation->rd_rel->relnamespace); + if (!relation->rd_istemp) + relation->rd_backend = InvalidBackendId; + else if (isTempOrToastNamespace(relation->rd_rel->relnamespace)) + relation->rd_backend = MyBackendId; else - relation->rd_islocaltemp = false; + { + /* + * If it's a temporary table, but not one of ours, we have to use + * the slow, grotty method to figure out the owning backend. + */ + relation->rd_backend = + GetTempNamespaceBackendId(relation->rd_rel->relnamespace); + Assert(relation->rd_backend != InvalidBackendId); + } /* * initialize the tuple descriptor (relation->rd_att). @@ -1424,7 +1434,7 @@ formrdesc(const char *relationName, Oid relationReltype, relation->rd_createSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; relation->rd_istemp = false; - relation->rd_islocaltemp = false; + relation->rd_backend = InvalidBackendId; /* * initialize relation tuple form @@ -2515,7 +2525,7 @@ RelationBuildLocalRelation(const char *relname, /* it is temporary if and only if it is in my temp-table namespace */ rel->rd_istemp = isTempOrToastNamespace(relnamespace); - rel->rd_islocaltemp = rel->rd_istemp; + rel->rd_backend = rel->rd_istemp ? MyBackendId : InvalidBackendId; /* * create a new tuple descriptor from the one passed in. We do this @@ -2629,7 +2639,7 @@ void RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid) { Oid newrelfilenode; - RelFileNode newrnode; + RelFileNodeBackend newrnode; Relation pg_class; HeapTuple tuple; Form_pg_class classform; @@ -2640,7 +2650,8 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid) TransactionIdIsNormal(freezeXid)); /* Allocate a new relfilenode */ - newrelfilenode = GetNewRelFileNode(relation->rd_rel->reltablespace, NULL); + newrelfilenode = GetNewRelFileNode(relation->rd_rel->reltablespace, NULL, + relation->rd_backend); /* * Get a writable copy of the pg_class tuple for the given relation. @@ -2660,9 +2671,10 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid) * NOTE: any conflict in relfilenode value will be caught here, if * GetNewRelFileNode messes up for any reason. */ - newrnode = relation->rd_node; - newrnode.relNode = newrelfilenode; - RelationCreateStorage(newrnode, relation->rd_istemp); + newrnode.node = relation->rd_node; + newrnode.node.relNode = newrelfilenode; + newrnode.backend = relation->rd_backend; + RelationCreateStorage(newrnode.node, relation->rd_istemp); smgrclosenode(newrnode); /* |