Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc419321

Browse files
committed
Remove unnecessary variables in _hash_splitbucket().
Commited9cc2b made it unnecessary to passstart_nblkno to _hash_splitbucket(), and for that matter unnecessary tohave the internal nblkno variable either. My compiler didn't complainabout that, but some did. I also rearranged the use of oblkno a bit tomake 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 parentee0d06c commitc419321

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
staticbool_hash_alloc_buckets(Relationrel,BlockNumberfirstblock,
3838
uint32nblocks);
3939
staticvoid_hash_splitbucket(Relationrel,Buffermetabuf,
40-
Buffernbuf,
4140
Bucketobucket,Bucketnbucket,
4241
BlockNumberstart_oblkno,
43-
BlockNumberstart_nblkno,
42+
Buffernbuf,
4443
uint32maxbucket,
4544
uint32highmask,uint32lowmask);
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
staticvoid
755755
_hash_splitbucket(Relationrel,
756756
Buffermetabuf,
757-
Buffernbuf,
758757
Bucketobucket,
759758
Bucketnbucket,
760759
BlockNumberstart_oblkno,
761-
BlockNumberstart_nblkno,
760+
Buffernbuf,
762761
uint32maxbucket,
763762
uint32highmask,
764763
uint32lowmask)
765764
{
766-
BlockNumberoblkno;
767-
BlockNumbernblkno;
768765
Bufferobuf;
769766
Pageopage;
770767
Pagenpage;
@@ -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+
BlockNumberoblkno;
804799
OffsetNumberooffnum;
805800
OffsetNumberomaxoffnum;
806801
OffsetNumberdeletable[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 neednblkno ornopaque within the loop */
845+
/* we don't need nopaque within the loop */
851846
}
852847

853848
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp