mirror of
https://github.com/postgres/postgres.git
synced 2025-05-15 19:15:29 +03:00
Remove unnecessary variables in _hash_splitbucket().
Commit ed9cc2b5df59fdbc50cce37399e26b03ab2c1686 made it unnecessary to pass start_nblkno to _hash_splitbucket(), and for that matter unnecessary to have the internal nblkno variable either. My compiler didn't complain about that, but some did. I also rearranged the use of oblkno a bit to make that case more parallel. Report and initial patch by Petr Jelinek, rearranged a bit by me. Back-patch to all branches, like the previous patch.
This commit is contained in:
parent
f4540cae10
commit
cbccaf22bf
@ -37,10 +37,9 @@
|
|||||||
static bool _hash_alloc_buckets(Relation rel, BlockNumber firstblock,
|
static bool _hash_alloc_buckets(Relation rel, BlockNumber firstblock,
|
||||||
uint32 nblocks);
|
uint32 nblocks);
|
||||||
static void _hash_splitbucket(Relation rel, Buffer metabuf,
|
static void _hash_splitbucket(Relation rel, Buffer metabuf,
|
||||||
Buffer nbuf,
|
|
||||||
Bucket obucket, Bucket nbucket,
|
Bucket obucket, Bucket nbucket,
|
||||||
BlockNumber start_oblkno,
|
BlockNumber start_oblkno,
|
||||||
BlockNumber start_nblkno,
|
Buffer nbuf,
|
||||||
uint32 maxbucket,
|
uint32 maxbucket,
|
||||||
uint32 highmask, uint32 lowmask);
|
uint32 highmask, uint32 lowmask);
|
||||||
|
|
||||||
@ -664,9 +663,9 @@ _hash_expandtable(Relation rel, Buffer metabuf)
|
|||||||
_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK);
|
_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK);
|
||||||
|
|
||||||
/* Relocate records to the new bucket */
|
/* Relocate records to the new bucket */
|
||||||
_hash_splitbucket(rel, metabuf, buf_nblkno,
|
_hash_splitbucket(rel, metabuf,
|
||||||
old_bucket, new_bucket,
|
old_bucket, new_bucket,
|
||||||
start_oblkno, start_nblkno,
|
start_oblkno, buf_nblkno,
|
||||||
maxbucket, highmask, lowmask);
|
maxbucket, highmask, lowmask);
|
||||||
|
|
||||||
/* Release bucket locks, allowing others to access them */
|
/* Release bucket locks, allowing others to access them */
|
||||||
@ -747,24 +746,22 @@ _hash_alloc_buckets(Relation rel, BlockNumber firstblock, uint32 nblocks)
|
|||||||
* touched if it becomes necessary to add or remove overflow pages.)
|
* touched if it becomes necessary to add or remove overflow pages.)
|
||||||
*
|
*
|
||||||
* In addition, the caller must have created the new bucket's base page,
|
* In addition, the caller must have created the new bucket's base page,
|
||||||
* which is passed in buffer nbuf, pinned and write-locked. The lock
|
* which is passed in buffer nbuf, pinned and write-locked. That lock and
|
||||||
* and pin are released here. (The API is set up this way because we must
|
* pin are released here. (The API is set up this way because we must do
|
||||||
* do _hash_getnewbuf() before releasing the metapage write lock.)
|
* _hash_getnewbuf() before releasing the metapage write lock. So instead of
|
||||||
|
* passing the new bucket's start block number, we pass an actual buffer.)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_hash_splitbucket(Relation rel,
|
_hash_splitbucket(Relation rel,
|
||||||
Buffer metabuf,
|
Buffer metabuf,
|
||||||
Buffer nbuf,
|
|
||||||
Bucket obucket,
|
Bucket obucket,
|
||||||
Bucket nbucket,
|
Bucket nbucket,
|
||||||
BlockNumber start_oblkno,
|
BlockNumber start_oblkno,
|
||||||
BlockNumber start_nblkno,
|
Buffer nbuf,
|
||||||
uint32 maxbucket,
|
uint32 maxbucket,
|
||||||
uint32 highmask,
|
uint32 highmask,
|
||||||
uint32 lowmask)
|
uint32 lowmask)
|
||||||
{
|
{
|
||||||
BlockNumber oblkno;
|
|
||||||
BlockNumber nblkno;
|
|
||||||
Buffer obuf;
|
Buffer obuf;
|
||||||
Page opage;
|
Page opage;
|
||||||
Page npage;
|
Page npage;
|
||||||
@ -776,13 +773,10 @@ _hash_splitbucket(Relation rel,
|
|||||||
* since no one else can be trying to acquire buffer lock on pages of
|
* since no one else can be trying to acquire buffer lock on pages of
|
||||||
* either bucket.
|
* either bucket.
|
||||||
*/
|
*/
|
||||||
oblkno = start_oblkno;
|
obuf = _hash_getbuf(rel, start_oblkno, HASH_WRITE, LH_BUCKET_PAGE);
|
||||||
obuf = _hash_getbuf(rel, oblkno, HASH_WRITE, LH_BUCKET_PAGE);
|
|
||||||
opage = BufferGetPage(obuf);
|
opage = BufferGetPage(obuf);
|
||||||
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
|
oopaque = (HashPageOpaque) PageGetSpecialPointer(opage);
|
||||||
|
|
||||||
nblkno = start_nblkno;
|
|
||||||
Assert(nblkno == BufferGetBlockNumber(nbuf));
|
|
||||||
npage = BufferGetPage(nbuf);
|
npage = BufferGetPage(nbuf);
|
||||||
|
|
||||||
/* initialize the new bucket's primary page */
|
/* initialize the new bucket's primary page */
|
||||||
@ -801,6 +795,7 @@ _hash_splitbucket(Relation rel,
|
|||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
BlockNumber oblkno;
|
||||||
OffsetNumber ooffnum;
|
OffsetNumber ooffnum;
|
||||||
OffsetNumber omaxoffnum;
|
OffsetNumber omaxoffnum;
|
||||||
OffsetNumber deletable[MaxOffsetNumber];
|
OffsetNumber deletable[MaxOffsetNumber];
|
||||||
@ -847,7 +842,7 @@ _hash_splitbucket(Relation rel,
|
|||||||
/* chain to a new overflow page */
|
/* chain to a new overflow page */
|
||||||
nbuf = _hash_addovflpage(rel, metabuf, nbuf);
|
nbuf = _hash_addovflpage(rel, metabuf, nbuf);
|
||||||
npage = BufferGetPage(nbuf);
|
npage = BufferGetPage(nbuf);
|
||||||
/* we don't need nblkno or nopaque within the loop */
|
/* we don't need nopaque within the loop */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user