diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-01-10 08:26:52 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-01-10 08:31:03 -0500 |
commit | e898437460f55b49623d1aea435cd92e0011d54d (patch) | |
tree | 8b7ecd13550885604184c31247dea476b5a8c236 /src | |
parent | 2ef6fe9cbae9fe7789a35cbc5fa1bbf78c163d42 (diff) | |
download | postgresql-e898437460f55b49623d1aea435cd92e0011d54d.tar.gz postgresql-e898437460f55b49623d1aea435cd92e0011d54d.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/hash/hashovfl.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index d2e8f6486bb..e8928efc1aa 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -128,11 +128,17 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin) break; /* 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); + } else _hash_relbuf(rel, buf); + retain_pin = false; + 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 */ pageopaque->hasho_nextblkno = BufferGetBlockNumber(ovflbuf); 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); + } else _hash_relbuf(rel, buf); |