Commit 14f81d8d authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Decrement relation reference count incremented in

RelationIdCacheGetRelation() to flush relations from cache
in commit time.
parent defb10a4
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.26 1997/09/22 07:13:56 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.27 1997/10/12 07:12:02 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -832,6 +832,8 @@ FlushBuffer(Buffer buffer, bool release) ...@@ -832,6 +832,8 @@ FlushBuffer(Buffer buffer, bool release)
status = smgrflush(bufHdr->bufsmgr, bufrel, bufHdr->tag.blockNum, status = smgrflush(bufHdr->bufsmgr, bufrel, bufHdr->tag.blockNum,
(char *) MAKE_PTR(bufHdr->data)); (char *) MAKE_PTR(bufHdr->data));
RelationDecrementReferenceCount(bufrel);
if (status == SM_FAIL) if (status == SM_FAIL)
{ {
...@@ -1065,15 +1067,8 @@ BufferSync() ...@@ -1065,15 +1067,8 @@ BufferSync()
* were flushing it out we must not clear DIRTY flag - * were flushing it out we must not clear DIRTY flag -
* vadim 01/17/97 * vadim 01/17/97
*/ */
if (bufHdr->flags & BM_JUST_DIRTIED) if (!(bufHdr->flags & BM_JUST_DIRTIED))
{
elog(NOTICE, "BufferSync: content of block %u (%s) changed while flushing",
bufHdr->tag.blockNum, bufHdr->sb_relname);
}
else
{
bufHdr->flags &= ~BM_DIRTY; bufHdr->flags &= ~BM_DIRTY;
}
if (reln != (Relation) NULL) if (reln != (Relation) NULL)
RelationDecrementReferenceCount(reln); RelationDecrementReferenceCount(reln);
} }
...@@ -1392,6 +1387,9 @@ BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld) ...@@ -1392,6 +1387,9 @@ BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld)
bufHdr->tag.blockNum, bufHdr->tag.blockNum,
(char *) MAKE_PTR(bufHdr->data)); (char *) MAKE_PTR(bufHdr->data));
} }
if (reln != (Relation) NULL)
RelationDecrementReferenceCount(reln);
if (status == SM_FAIL) if (status == SM_FAIL)
return (FALSE); return (FALSE);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.12 1997/09/18 20:21:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.13 1997/10/12 07:12:03 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -127,6 +127,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) ...@@ -127,6 +127,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
smgrwrite(bufrel->rd_rel->relsmgr, bufrel, bufHdr->tag.blockNum, smgrwrite(bufrel->rd_rel->relsmgr, bufrel, bufHdr->tag.blockNum,
(char *) MAKE_PTR(bufHdr->data)); (char *) MAKE_PTR(bufHdr->data));
LocalBufferFlushCount++; LocalBufferFlushCount++;
RelationDecrementReferenceCount(bufrel);
} }
/* /*
...@@ -204,7 +205,8 @@ FlushLocalBuffer(Buffer buffer, bool release) ...@@ -204,7 +205,8 @@ FlushLocalBuffer(Buffer buffer, bool release)
smgrflush(bufrel->rd_rel->relsmgr, bufrel, bufHdr->tag.blockNum, smgrflush(bufrel->rd_rel->relsmgr, bufrel, bufHdr->tag.blockNum,
(char *) MAKE_PTR(bufHdr->data)); (char *) MAKE_PTR(bufHdr->data));
LocalBufferFlushCount++; LocalBufferFlushCount++;
RelationDecrementReferenceCount(bufrel);
Assert(LocalRefCount[bufid] > 0); Assert(LocalRefCount[bufid] > 0);
if (release) if (release)
LocalRefCount[bufid]--; LocalRefCount[bufid]--;
...@@ -277,7 +279,8 @@ LocalBufferSync(void) ...@@ -277,7 +279,8 @@ LocalBufferSync(void)
smgrwrite(bufrel->rd_rel->relsmgr, bufrel, buf->tag.blockNum, smgrwrite(bufrel->rd_rel->relsmgr, bufrel, buf->tag.blockNum,
(char *) MAKE_PTR(buf->data)); (char *) MAKE_PTR(buf->data));
LocalBufferFlushCount++; LocalBufferFlushCount++;
RelationDecrementReferenceCount(bufrel);
buf->tag.relId.relId = InvalidOid; buf->tag.relId.relId = InvalidOid;
buf->flags &= ~BM_DIRTY; buf->flags &= ~BM_DIRTY;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment