Content-Length: 297259 | pFad | http://github.com/postgrespro/postgres_cluster/commit/e898437460f55b49623d1aea435cd92e0011d54d

A8 Improve coding in _hash_addovflpage. · postgrespro/postgres_cluster@e898437 · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/e898437460f55b49623d1aea435cd92e0011d54d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy