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