Skip to content

Commit e898437

Browse files
committed
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.
1 parent 2ef6fe9 commit e898437

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/access/hash/hashovfl.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,17 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin)
128128
break;
129129

130130
/* we assume we do not need to write the unmodified page */
131-
if ((pageopaque->hasho_flag & LH_BUCKET_PAGE) && retain_pin)
131+
if (retain_pin)
132+
{
133+
/* pin will be retained only for the primary bucket page */
134+
Assert(pageopaque->hasho_flag & LH_BUCKET_PAGE);
132135
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
136+
}
133137
else
134138
_hash_relbuf(rel, buf);
135139

140+
retain_pin = false;
141+
136142
buf = _hash_getbuf(rel, nextblkno, HASH_WRITE, LH_OVERFLOW_PAGE);
137143
}
138144

@@ -150,8 +156,12 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin)
150156
/* logically chain overflow page to previous page */
151157
pageopaque->hasho_nextblkno = BufferGetBlockNumber(ovflbuf);
152158
MarkBufferDirty(buf);
153-
if ((pageopaque->hasho_flag & LH_BUCKET_PAGE) && retain_pin)
159+
if (retain_pin)
160+
{
161+
/* pin will be retained only for the primary bucket page */
162+
Assert(pageopaque->hasho_flag & LH_BUCKET_PAGE);
154163
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
164+
}
155165
else
156166
_hash_relbuf(rel, buf);
157167

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy