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

Commit3b82837

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 parent276591b commit3b82837

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
@@ -40,10 +40,9 @@
4040
staticbool_hash_alloc_buckets(Relationrel,BlockNumberfirstblock,
4141
uint32nblocks);
4242
staticvoid_hash_splitbucket(Relationrel,Buffermetabuf,
43-
Buffernbuf,
4443
Bucketobucket,Bucketnbucket,
4544
BlockNumberstart_oblkno,
46-
BlockNumberstart_nblkno,
45+
Buffernbuf,
4746
uint32maxbucket,
4847
uint32highmask,uint32lowmask);
4948

@@ -682,9 +681,9 @@ _hash_expandtable(Relation rel, Buffer metabuf)
682681
_hash_droplock(rel,0,HASH_EXCLUSIVE);
683682

684683
/* Relocate records to the new bucket */
685-
_hash_splitbucket(rel,metabuf,buf_nblkno,
684+
_hash_splitbucket(rel,metabuf,
686685
old_bucket,new_bucket,
687-
start_oblkno,start_nblkno,
686+
start_oblkno,buf_nblkno,
688687
maxbucket,highmask,lowmask);
689688

690689
/* Release bucket locks, allowing others to access them */
@@ -768,24 +767,22 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
768767
* touched if it becomes necessary to add or remove overflow pages.)
769768
*
770769
* In addition, the caller must have created the new bucket's base page,
771-
* which is passed in buffer nbuf, pinned and write-locked. The lock
772-
* and pin are released here. (The API is set up this way because we must
773-
* do _hash_getnewbuf() before releasing the metapage write lock.)
770+
* which is passed in buffer nbuf, pinned and write-locked. That lock and
771+
* pin are released here. (The API is set up this way because we must do
772+
* _hash_getnewbuf() before releasing the metapage write lock. So instead of
773+
* passing the new bucket's start block number, we pass an actual buffer.)
774774
*/
775775
staticvoid
776776
_hash_splitbucket(Relationrel,
777777
Buffermetabuf,
778-
Buffernbuf,
779778
Bucketobucket,
780779
Bucketnbucket,
781780
BlockNumberstart_oblkno,
782-
BlockNumberstart_nblkno,
781+
Buffernbuf,
783782
uint32maxbucket,
784783
uint32highmask,
785784
uint32lowmask)
786785
{
787-
BlockNumberoblkno;
788-
BlockNumbernblkno;
789786
Bufferobuf;
790787
Pageopage;
791788
Pagenpage;
@@ -797,13 +794,10 @@ _hash_splitbucket(Relation rel,
797794
* since no one else can be trying to acquire buffer lock on pages of
798795
* either bucket.
799796
*/
800-
oblkno=start_oblkno;
801-
obuf=_hash_getbuf(rel,oblkno,HASH_WRITE,LH_BUCKET_PAGE);
797+
obuf=_hash_getbuf(rel,start_oblkno,HASH_WRITE,LH_BUCKET_PAGE);
802798
opage=BufferGetPage(obuf);
803799
oopaque= (HashPageOpaque)PageGetSpecialPointer(opage);
804800

805-
nblkno=start_nblkno;
806-
Assert(nblkno==BufferGetBlockNumber(nbuf));
807801
npage=BufferGetPage(nbuf);
808802

809803
/* initialize the new bucket's primary page */
@@ -822,6 +816,7 @@ _hash_splitbucket(Relation rel,
822816
*/
823817
for (;;)
824818
{
819+
BlockNumberoblkno;
825820
OffsetNumberooffnum;
826821
OffsetNumberomaxoffnum;
827822
OffsetNumberdeletable[MaxOffsetNumber];
@@ -868,7 +863,7 @@ _hash_splitbucket(Relation rel,
868863
/* chain to a new overflow page */
869864
nbuf=_hash_addovflpage(rel,metabuf,nbuf);
870865
npage=BufferGetPage(nbuf);
871-
/* we don't neednblkno ornopaque within the loop */
866+
/* we don't need nopaque within the loop */
872867
}
873868

874869
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp