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

Commit0aff9d8

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 parentd4bacdc commit0aff9d8

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

@@ -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
staticvoid
773773
_hash_splitbucket(Relationrel,
774774
Buffermetabuf,
775-
Buffernbuf,
776775
Bucketobucket,
777776
Bucketnbucket,
778777
BlockNumberstart_oblkno,
779-
BlockNumberstart_nblkno,
778+
Buffernbuf,
780779
uint32maxbucket,
781780
uint32highmask,
782781
uint32lowmask)
783782
{
784-
BlockNumberoblkno;
785-
BlockNumbernblkno;
786783
Bufferobuf;
787784
Pageopage;
788785
Pagenpage;
@@ -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+
BlockNumberoblkno;
822817
OffsetNumberooffnum;
823818
OffsetNumberomaxoffnum;
824819
OffsetNumberdeletable[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 neednblkno ornopaque within the loop */
863+
/* we don't need nopaque within the loop */
869864
}
870865

871866
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp