Skip to content

Commit c419321

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 ee0d06c commit c419321

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

@@ -664,9 +663,9 @@ _hash_expandtable(Relation rel, Buffer metabuf)
664663
_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK);
665664

666665
/* Relocate records to the new bucket */
667-
_hash_splitbucket(rel, metabuf, buf_nblkno,
666+
_hash_splitbucket(rel, metabuf,
668667
old_bucket, new_bucket,
669-
start_oblkno, start_nblkno,
668+
start_oblkno, buf_nblkno,
670669
maxbucket, highmask, lowmask);
671670

672671
/* Release bucket locks, allowing others to access them */
@@ -747,24 +746,22 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
747746
* touched if it becomes necessary to add or remove overflow pages.)
748747
*
749748
* In addition, the caller must have created the new bucket's base page,
750-
* which is passed in buffer nbuf, pinned and write-locked. The lock
751-
* and pin are released here. (The API is set up this way because we must
752-
* do _hash_getnewbuf() before releasing the metapage write lock.)
749+
* which is passed in buffer nbuf, pinned and write-locked. That lock and
750+
* pin are released here. (The API is set up this way because we must do
751+
* _hash_getnewbuf() before releasing the metapage write lock. So instead of
752+
* passing the new bucket's start block number, we pass an actual buffer.)
753753
*/
754754
static void
755755
_hash_splitbucket(Relation rel,
756756
Buffer metabuf,
757-
Buffer nbuf,
758757
Bucket obucket,
759758
Bucket nbucket,
760759
BlockNumber start_oblkno,
761-
BlockNumber start_nblkno,
760+
Buffer nbuf,
762761
uint32 maxbucket,
763762
uint32 highmask,
764763
uint32 lowmask)
765764
{
766-
BlockNumber oblkno;
767-
BlockNumber nblkno;
768765
Buffer obuf;
769766
Page opage;
770767
Page npage;
@@ -776,13 +773,10 @@ _hash_splitbucket(Relation rel,
776773
* since no one else can be trying to acquire buffer lock on pages of
777774
* either bucket.
778775
*/
779-
oblkno = start_oblkno;
780-
obuf = _hash_getbuf(rel, oblkno, HASH_WRITE, LH_BUCKET_PAGE);
776+
obuf = _hash_getbuf(rel, start_oblkno, HASH_WRITE, LH_BUCKET_PAGE);
781777
opage = BufferGetPage(obuf);
782778
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
783779

784-
nblkno = start_nblkno;
785-
Assert(nblkno == BufferGetBlockNumber(nbuf));
786780
npage = BufferGetPage(nbuf);
787781

788782
/* initialize the new bucket's primary page */
@@ -801,6 +795,7 @@ _hash_splitbucket(Relation rel,
801795
*/
802796
for (;;)
803797
{
798+
BlockNumber oblkno;
804799
OffsetNumber ooffnum;
805800
OffsetNumber omaxoffnum;
806801
OffsetNumber deletable[MaxOffsetNumber];
@@ -847,7 +842,7 @@ _hash_splitbucket(Relation rel,
847842
/* chain to a new overflow page */
848843
nbuf = _hash_addovflpage(rel, metabuf, nbuf);
849844
npage = BufferGetPage(nbuf);
850-
/* we don't need nblkno or nopaque within the loop */
845+
/* we don't need nopaque within the loop */
851846
}
852847

853848
/*

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