3737static bool _hash_alloc_buckets (Relation rel , BlockNumber firstblock ,
3838 uint32 nblocks );
3939static void _hash_splitbucket (Relation rel , Buffer metabuf ,
40- Buffer nbuf ,
4140 Bucket obucket , Bucket nbucket ,
4241 BlockNumber start_oblkno ,
43- BlockNumber start_nblkno ,
42+ Buffer nbuf ,
4443 uint32 maxbucket ,
4544 uint32 highmask , uint32 lowmask );
4645
@@ -679,9 +678,9 @@ _hash_expandtable(Relation rel, Buffer metabuf)
679678 _hash_droplock (rel , 0 , HASH_EXCLUSIVE );
680679
681680 /* Relocate records to the new bucket */
682- _hash_splitbucket (rel , metabuf , buf_nblkno ,
681+ _hash_splitbucket (rel , metabuf ,
683682 old_bucket , new_bucket ,
684- start_oblkno , start_nblkno ,
683+ start_oblkno , buf_nblkno ,
685684 maxbucket , highmask , lowmask );
686685
687686 /* Release bucket locks, allowing others to access them */
@@ -765,24 +764,22 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
765764 * touched if it becomes necessary to add or remove overflow pages.)
766765 *
767766 * 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.)
771771 */
772772static void
773773_hash_splitbucket (Relation rel ,
774774 Buffer metabuf ,
775- Buffer nbuf ,
776775 Bucket obucket ,
777776 Bucket nbucket ,
778777 BlockNumber start_oblkno ,
779- BlockNumber start_nblkno ,
778+ Buffer nbuf ,
780779 uint32 maxbucket ,
781780 uint32 highmask ,
782781 uint32 lowmask )
783782{
784- BlockNumber oblkno ;
785- BlockNumber nblkno ;
786783 Buffer obuf ;
787784 Page opage ;
788785 Page npage ;
@@ -794,13 +791,10 @@ _hash_splitbucket(Relation rel,
794791 * since no one else can be trying to acquire buffer lock on pages of
795792 * either bucket.
796793 */
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 );
799795 opage = BufferGetPage (obuf );
800796 oopaque = (HashPageOpaque ) PageGetSpecialPointer (opage );
801797
802- nblkno = start_nblkno ;
803- Assert (nblkno == BufferGetBlockNumber (nbuf ));
804798 npage = BufferGetPage (nbuf );
805799
806800 /* initialize the new bucket's primary page */
@@ -819,6 +813,7 @@ _hash_splitbucket(Relation rel,
819813 */
820814 for (;;)
821815 {
816+ BlockNumber oblkno ;
822817 OffsetNumber ooffnum ;
823818 OffsetNumber omaxoffnum ;
824819 OffsetNumber deletable [MaxOffsetNumber ];
@@ -865,7 +860,7 @@ _hash_splitbucket(Relation rel,
865860 /* chain to a new overflow page */
866861 nbuf = _hash_addovflpage (rel , metabuf , nbuf );
867862 npage = BufferGetPage (nbuf );
868- /* we don't need nblkno or nopaque within the loop */
863+ /* we don't need nopaque within the loop */
869864 }
870865
871866 /*
0 commit comments