Skip to content

Commit 0aff9d8

Browse files
committed
Remove unnecessary variables in _hash_splitbucket().
Commit ed9cc2b made it unnecessary to pass start_nblkno to _hash_splitbucket(), and for that matter unnecessary to have the internal nblkno variable either. My compiler didn't complain about that, but some did. I also rearranged the use of oblkno a bit to make that case more parallel. Report and initial patch by Petr Jelinek, rearranged a bit by me. Back-patch to all branches, like the previous patch.
1 parent d4bacdc commit 0aff9d8

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/backend/access/hash/hashpage.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
static bool _hash_alloc_buckets(Relation rel, BlockNumber firstblock,
3838
uint32 nblocks);
3939
static void _hash_splitbucket(Relation rel, Buffer metabuf,
40-
Buffer nbuf,
4140
Bucket obucket, Bucket nbucket,
4241
BlockNumber start_oblkno,
43-
BlockNumber start_nblkno,
42+
Buffer nbuf,
4443
uint32 maxbucket,
4544
uint32 highmask, uint32 lowmask);
4645

@@ -679,9 +678,9 @@ _hash_expandtable(Relation rel, Buffer metabuf)
679678
_hash_droplock(rel, 0, HASH_EXCLUSIVE);
680679

681680
/* Relocate records to the new bucket */
682-
_hash_splitbucket(rel, metabuf, buf_nblkno,
681+
_hash_splitbucket(rel, metabuf,
683682
old_bucket, new_bucket,
684-
start_oblkno, start_nblkno,
683+
start_oblkno, buf_nblkno,
685684
maxbucket, highmask, lowmask);
686685

687686
/* Release bucket locks, allowing others to access them */
@@ -765,24 +764,22 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
765764
* touched if it becomes necessary to add or remove overflow pages.)
766765
*
767766
* In addition, the caller must have created the new bucket's base page,
768-
* which is passed in buffer nbuf, pinned and write-locked. The lock
769-
* and pin are released here. (The API is set up this way because we must
770-
* do _hash_getnewbuf() before releasing the metapage write lock.)
767+
* which is passed in buffer nbuf, pinned and write-locked. That lock and
768+
* pin are released here. (The API is set up this way because we must do
769+
* _hash_getnewbuf() before releasing the metapage write lock. So instead of
770+
* passing the new bucket's start block number, we pass an actual buffer.)
771771
*/
772772
static void
773773
_hash_splitbucket(Relation rel,
774774
Buffer metabuf,
775-
Buffer nbuf,
776775
Bucket obucket,
777776
Bucket nbucket,
778777
BlockNumber start_oblkno,
779-
BlockNumber start_nblkno,
778+
Buffer nbuf,
780779
uint32 maxbucket,
781780
uint32 highmask,
782781
uint32 lowmask)
783782
{
784-
BlockNumber oblkno;
785-
BlockNumber nblkno;
786783
Buffer obuf;
787784
Page opage;
788785
Page npage;
@@ -794,13 +791,10 @@ _hash_splitbucket(Relation rel,
794791
* since no one else can be trying to acquire buffer lock on pages of
795792
* either bucket.
796793
*/
797-
oblkno = start_oblkno;
798-
obuf = _hash_getbuf(rel, oblkno, HASH_WRITE, LH_BUCKET_PAGE);
794+
obuf = _hash_getbuf(rel, start_oblkno, HASH_WRITE, LH_BUCKET_PAGE);
799795
opage = BufferGetPage(obuf);
800796
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
801797

802-
nblkno = start_nblkno;
803-
Assert(nblkno == BufferGetBlockNumber(nbuf));
804798
npage = BufferGetPage(nbuf);
805799

806800
/* initialize the new bucket's primary page */
@@ -819,6 +813,7 @@ _hash_splitbucket(Relation rel,
819813
*/
820814
for (;;)
821815
{
816+
BlockNumber oblkno;
822817
OffsetNumber ooffnum;
823818
OffsetNumber omaxoffnum;
824819
OffsetNumber deletable[MaxOffsetNumber];
@@ -865,7 +860,7 @@ _hash_splitbucket(Relation rel,
865860
/* chain to a new overflow page */
866861
nbuf = _hash_addovflpage(rel, metabuf, nbuf);
867862
npage = BufferGetPage(nbuf);
868-
/* we don't need nblkno or nopaque within the loop */
863+
/* we don't need nopaque within the loop */
869864
}
870865

871866
/*

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