37
37
static bool _hash_alloc_buckets (Relation rel , BlockNumber firstblock ,
38
38
uint32 nblocks );
39
39
static void _hash_splitbucket (Relation rel , Buffer metabuf ,
40
- Buffer nbuf ,
41
40
Bucket obucket , Bucket nbucket ,
42
41
BlockNumber start_oblkno ,
43
- BlockNumber start_nblkno ,
42
+ Buffer nbuf ,
44
43
uint32 maxbucket ,
45
44
uint32 highmask , uint32 lowmask );
46
45
@@ -679,9 +678,9 @@ _hash_expandtable(Relation rel, Buffer metabuf)
679
678
_hash_droplock (rel , 0 , HASH_EXCLUSIVE );
680
679
681
680
/* Relocate records to the new bucket */
682
- _hash_splitbucket (rel , metabuf , buf_nblkno ,
681
+ _hash_splitbucket (rel , metabuf ,
683
682
old_bucket , new_bucket ,
684
- start_oblkno , start_nblkno ,
683
+ start_oblkno , buf_nblkno ,
685
684
maxbucket , highmask , lowmask );
686
685
687
686
/* Release bucket locks, allowing others to access them */
@@ -765,24 +764,22 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
765
764
* touched if it becomes necessary to add or remove overflow pages.)
766
765
*
767
766
* 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.)
771
771
*/
772
772
static void
773
773
_hash_splitbucket (Relation rel ,
774
774
Buffer metabuf ,
775
- Buffer nbuf ,
776
775
Bucket obucket ,
777
776
Bucket nbucket ,
778
777
BlockNumber start_oblkno ,
779
- BlockNumber start_nblkno ,
778
+ Buffer nbuf ,
780
779
uint32 maxbucket ,
781
780
uint32 highmask ,
782
781
uint32 lowmask )
783
782
{
784
- BlockNumber oblkno ;
785
- BlockNumber nblkno ;
786
783
Buffer obuf ;
787
784
Page opage ;
788
785
Page npage ;
@@ -794,13 +791,10 @@ _hash_splitbucket(Relation rel,
794
791
* since no one else can be trying to acquire buffer lock on pages of
795
792
* either bucket.
796
793
*/
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 );
799
795
opage = BufferGetPage (obuf );
800
796
oopaque = (HashPageOpaque ) PageGetSpecialPointer (opage );
801
797
802
- nblkno = start_nblkno ;
803
- Assert (nblkno == BufferGetBlockNumber (nbuf ));
804
798
npage = BufferGetPage (nbuf );
805
799
806
800
/* initialize the new bucket's primary page */
@@ -819,6 +813,7 @@ _hash_splitbucket(Relation rel,
819
813
*/
820
814
for (;;)
821
815
{
816
+ BlockNumber oblkno ;
822
817
OffsetNumber ooffnum ;
823
818
OffsetNumber omaxoffnum ;
824
819
OffsetNumber deletable [MaxOffsetNumber ];
@@ -865,7 +860,7 @@ _hash_splitbucket(Relation rel,
865
860
/* chain to a new overflow page */
866
861
nbuf = _hash_addovflpage (rel , metabuf , nbuf );
867
862
npage = BufferGetPage (nbuf );
868
- /* we don't need nblkno or nopaque within the loop */
863
+ /* we don't need nopaque within the loop */
869
864
}
870
865
871
866
/*
0 commit comments