Content-Length: 391773 | pFad | http://github.com/postgrespro/postgres/commit/645081427d52bdfa88b79d886df2cbab5c72d406

C3 Remove unnecessary variables in _hash_splitbucket(). · postgrespro/postgres@6450814 · GitHub
Skip to content

Commit 6450814

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 557fcfa commit 6450814

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
static bool _hash_alloc_buckets(Relation rel, BlockNumber firstblock,
4141
uint32 nblocks);
4242
static void _hash_splitbucket(Relation rel, Buffer metabuf,
43-
Buffer nbuf,
4443
Bucket obucket, Bucket nbucket,
4544
BlockNumber start_oblkno,
46-
BlockNumber start_nblkno,
45+
Buffer nbuf,
4746
uint32 maxbucket,
4847
uint32 highmask, uint32 lowmask);
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
static void
776776
_hash_splitbucket(Relation rel,
777777
Buffer metabuf,
778-
Buffer nbuf,
779778
Bucket obucket,
780779
Bucket nbucket,
781780
BlockNumber start_oblkno,
782-
BlockNumber start_nblkno,
781+
Buffer nbuf,
783782
uint32 maxbucket,
784783
uint32 highmask,
785784
uint32 lowmask)
786785
{
787-
BlockNumber oblkno;
788-
BlockNumber nblkno;
789786
Buffer obuf;
790787
Page opage;
791788
Page npage;
@@ -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+
BlockNumber oblkno;
825820
OffsetNumber ooffnum;
826821
OffsetNumber omaxoffnum;
827822
OffsetNumber deletable[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 need nblkno or nopaque within the loop */
866+
/* we don't need nopaque within the loop */
872867
}
873868

874869
/*

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/645081427d52bdfa88b79d886df2cbab5c72d406

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy