Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5fb82eb

Browse files
committed
Blowaway relation buffers from buffer pool before truncation:
+ BlowawayRelationBuffers(relation, blocknumber)
1 parent708f67c commit5fb82eb

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.25 1997/09/18 20:21:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.26 1997/09/22 07:13:56 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -99,6 +99,9 @@ static intFlushBuffer(Buffer buffer, bool release);
9999
staticvoidBufferSync(void);
100100
staticintBufferReplace(BufferDesc*bufHdr,boolbufferLockHeld);
101101

102+
/* not static but used by vacuum only ... */
103+
intBlowawayRelationBuffers(Relationrdesc,BlockNumberblock);
104+
102105
/* ---------------------------------------------------
103106
* RelationGetBufferWithBuffer
104107
*see if the given buffer is what we want
@@ -1603,6 +1606,67 @@ BufferPoolBlowaway()
16031606

16041607
#endif
16051608

1609+
/* ---------------------------------------------------------------------
1610+
*BlowawayRelationBuffers
1611+
*
1612+
*This function blowaway all the pages with blocknumber >= passed
1613+
*of a relation in the buffer pool. Used by vacuum before truncation...
1614+
*
1615+
*Returns: 0 - Ok, -1 - DIRTY, -2 - PINNED
1616+
*
1617+
*XXX currently it sequentially searches the buffer pool, should be
1618+
*changed to more clever ways of searching.
1619+
* --------------------------------------------------------------------
1620+
*/
1621+
int
1622+
BlowawayRelationBuffers(Relationrdesc,BlockNumberblock)
1623+
{
1624+
registerinti;
1625+
BufferDesc*buf;
1626+
1627+
if (rdesc->rd_islocal)
1628+
{
1629+
for (i=0;i<NLocBuffer;i++)
1630+
{
1631+
buf=&LocalBufferDescriptors[i];
1632+
if (buf->tag.relId.relId==rdesc->rd_id&&
1633+
buf->tag.blockNum >=block)
1634+
{
1635+
if (buf->flags&BM_DIRTY)
1636+
return (-1);
1637+
if (LocalRefCount[i]>0)
1638+
return (-2);
1639+
buf->tag.relId.relId=InvalidOid;
1640+
}
1641+
}
1642+
return (0);
1643+
}
1644+
1645+
SpinAcquire(BufMgrLock);
1646+
for (i=0;i<NBuffers;i++)
1647+
{
1648+
buf=&BufferDescriptors[i];
1649+
if (buf->tag.relId.dbId==MyDatabaseId&&
1650+
buf->tag.relId.relId==rdesc->rd_id&&
1651+
buf->tag.blockNum >=block)
1652+
{
1653+
if (buf->flags&BM_DIRTY)
1654+
{
1655+
SpinRelease(BufMgrLock);
1656+
return (-1);
1657+
}
1658+
if (!(buf->flags&BM_FREE))
1659+
{
1660+
SpinRelease(BufMgrLock);
1661+
return (-2);
1662+
}
1663+
BufTableDelete(buf);
1664+
}
1665+
}
1666+
SpinRelease(BufMgrLock);
1667+
return (0);
1668+
}
1669+
16061670
#undef IncrBufferRefCount
16071671
#undef ReleaseBuffer
16081672

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp