4040static bool _hash_alloc_buckets (Relation rel , BlockNumber firstblock ,
4141 uint32 nblocks );
4242static 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 */
775775static 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