3737static bool _hash_alloc_buckets (Relation rel ,BlockNumber firstblock ,
3838uint32 nblocks );
3939static void _hash_splitbucket (Relation rel ,Buffer metabuf ,
40- Buffer nbuf ,
4140Bucket obucket ,Bucket nbucket ,
4241BlockNumber start_oblkno ,
43- BlockNumber start_nblkno ,
42+ Buffer nbuf ,
4443uint32 maxbucket ,
4544uint32 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 ,
683682old_bucket ,new_bucket ,
684- start_oblkno ,start_nblkno ,
683+ start_oblkno ,buf_nblkno ,
685684maxbucket ,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 ,
774774Buffer metabuf ,
775- Buffer nbuf ,
776775Bucket obucket ,
777776Bucket nbucket ,
778777BlockNumber start_oblkno ,
779- BlockNumber start_nblkno ,
778+ Buffer nbuf ,
780779uint32 maxbucket ,
781780uint32 highmask ,
782781uint32 lowmask )
783782{
784- BlockNumber oblkno ;
785- BlockNumber nblkno ;
786783Buffer obuf ;
787784Page opage ;
788785Page 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 );
799795opage = BufferGetPage (obuf );
800796oopaque = (HashPageOpaque )PageGetSpecialPointer (opage );
801797
802- nblkno = start_nblkno ;
803- Assert (nblkno == BufferGetBlockNumber (nbuf ));
804798npage = BufferGetPage (nbuf );
805799
806800/* initialize the new bucket's primary page */
@@ -819,6 +813,7 @@ _hash_splitbucket(Relation rel,
819813 */
820814for (;;)
821815{
816+ BlockNumber oblkno ;
822817OffsetNumber ooffnum ;
823818OffsetNumber omaxoffnum ;
824819OffsetNumber deletable [MaxOffsetNumber ];
@@ -865,7 +860,7 @@ _hash_splitbucket(Relation rel,
865860/* chain to a new overflow page */
866861nbuf = _hash_addovflpage (rel ,metabuf ,nbuf );
867862npage = BufferGetPage (nbuf );
868- /* we don't neednblkno or nopaque within the loop */
863+ /* we don't need nopaque within the loop */
869864}
870865
871866/*