diff options
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 1ca7af3b775..11df91c25cf 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.128 2002/08/06 02:36:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.129 2002/08/11 21:17:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1038,11 +1038,6 @@ BufferReplace(BufferDesc *bufHdr) * RelationGetNumberOfBlocks * Determines the current number of pages in the relation. * Side effect: relation->rd_nblocks is updated. - * - * Note: - * XXX may fail for huge relations. - * XXX should be elsewhere. - * XXX maybe should be hidden */ BlockNumber RelationGetNumberOfBlocks(Relation relation) @@ -1061,6 +1056,23 @@ RelationGetNumberOfBlocks(Relation relation) return relation->rd_nblocks; } +/* + * RelationUpdateNumberOfBlocks + * Forcibly update relation->rd_nblocks. + * + * If the relcache drops an entry for a temp relation, it must call this + * routine after recreating the relcache entry, so that rd_nblocks is + * re-sync'd with reality. See RelationGetNumberOfBlocks. + */ +void +RelationUpdateNumberOfBlocks(Relation relation) +{ + if (relation->rd_rel->relkind == RELKIND_VIEW) + relation->rd_nblocks = 0; + else + relation->rd_nblocks = smgrnblocks(DEFAULT_SMGR, relation); +} + /* --------------------------------------------------------------------- * DropRelationBuffers * |