mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Improve coding in _hash_addovflpage.
Instead of relying on the page contents to know whether we have advanced from the primary bucket page to an overflow page, track that explicitly. Amit Kapila, per a complaint by me.
This commit is contained in:
@ -128,11 +128,17 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* we assume we do not need to write the unmodified page */
|
/* we assume we do not need to write the unmodified page */
|
||||||
if ((pageopaque->hasho_flag & LH_BUCKET_PAGE) && retain_pin)
|
if (retain_pin)
|
||||||
|
{
|
||||||
|
/* pin will be retained only for the primary bucket page */
|
||||||
|
Assert(pageopaque->hasho_flag & LH_BUCKET_PAGE);
|
||||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_hash_relbuf(rel, buf);
|
_hash_relbuf(rel, buf);
|
||||||
|
|
||||||
|
retain_pin = false;
|
||||||
|
|
||||||
buf = _hash_getbuf(rel, nextblkno, HASH_WRITE, LH_OVERFLOW_PAGE);
|
buf = _hash_getbuf(rel, nextblkno, HASH_WRITE, LH_OVERFLOW_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +156,12 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin)
|
|||||||
/* logically chain overflow page to previous page */
|
/* logically chain overflow page to previous page */
|
||||||
pageopaque->hasho_nextblkno = BufferGetBlockNumber(ovflbuf);
|
pageopaque->hasho_nextblkno = BufferGetBlockNumber(ovflbuf);
|
||||||
MarkBufferDirty(buf);
|
MarkBufferDirty(buf);
|
||||||
if ((pageopaque->hasho_flag & LH_BUCKET_PAGE) && retain_pin)
|
if (retain_pin)
|
||||||
|
{
|
||||||
|
/* pin will be retained only for the primary bucket page */
|
||||||
|
Assert(pageopaque->hasho_flag & LH_BUCKET_PAGE);
|
||||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_hash_relbuf(rel, buf);
|
_hash_relbuf(rel, buf);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user