4040static bool _hash_alloc_buckets (Relation rel ,BlockNumber firstblock ,
4141uint32 nblocks );
4242static void _hash_splitbucket (Relation rel ,Buffer metabuf ,
43- Buffer nbuf ,
4443Bucket obucket ,Bucket nbucket ,
4544BlockNumber start_oblkno ,
46- BlockNumber start_nblkno ,
45+ Buffer nbuf ,
4746uint32 maxbucket ,
4847uint32 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 ,
686685old_bucket ,new_bucket ,
687- start_oblkno ,start_nblkno ,
686+ start_oblkno ,buf_nblkno ,
688687maxbucket ,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 ,
777777Buffer metabuf ,
778- Buffer nbuf ,
779778Bucket obucket ,
780779Bucket nbucket ,
781780BlockNumber start_oblkno ,
782- BlockNumber start_nblkno ,
781+ Buffer nbuf ,
783782uint32 maxbucket ,
784783uint32 highmask ,
785784uint32 lowmask )
786785{
787- BlockNumber oblkno ;
788- BlockNumber nblkno ;
789786Buffer obuf ;
790787Page opage ;
791788Page 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 );
802798opage = BufferGetPage (obuf );
803799oopaque = (HashPageOpaque )PageGetSpecialPointer (opage );
804800
805- nblkno = start_nblkno ;
806- Assert (nblkno == BufferGetBlockNumber (nbuf ));
807801npage = BufferGetPage (nbuf );
808802
809803/* initialize the new bucket's primary page */
@@ -822,6 +816,7 @@ _hash_splitbucket(Relation rel,
822816 */
823817for (;;)
824818{
819+ BlockNumber oblkno ;
825820OffsetNumber ooffnum ;
826821OffsetNumber omaxoffnum ;
827822OffsetNumber deletable [MaxOffsetNumber ];
@@ -868,7 +863,7 @@ _hash_splitbucket(Relation rel,
868863/* chain to a new overflow page */
869864nbuf = _hash_addovflpage (rel ,metabuf ,nbuf );
870865npage = BufferGetPage (nbuf );
871- /* we don't neednblkno or nopaque within the loop */
866+ /* we don't need nopaque within the loop */
872867}
873868
874869/*