aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/bufmgr.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-11 21:17:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-11 21:17:35 +0000
commite44beef712144316cb83d32ccf3231a1503c9655 (patch)
tree1b8cd8ecdc55866d61fcb44f4b5162303d9f023c /src/backend/storage/buffer/bufmgr.c
parent9bccdf17f725550e463fbc9fddf0acf2ed3a8e66 (diff)
downloadpostgresql-e44beef712144316cb83d32ccf3231a1503c9655.tar.gz
postgresql-e44beef712144316cb83d32ccf3231a1503c9655.zip
Code review of CLUSTER patch. Clean up problems with relcache getting
confused, toasted data getting lost, etc.
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r--src/backend/storage/buffer/bufmgr.c24
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
*