mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Preliminary cleanup for hash index code (doesn't attack the locking problem
yet). Fix a couple of bugs that would only appear if multiple bitmap pages are used, including a buffer reference leak and incorrect computation of bit indexes. Get rid of 'overflow address' concept, which accomplished nothing except obfuscating the code and creating a risk of failure due to limited range of offset field. Rename some misleadingly-named fields and routines, and improve documentation.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.27 2003/08/04 02:39:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.28 2003/09/01 20:26:34 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -155,7 +155,7 @@ _hash_insertonpg(Relation rel,
|
||||
* page with enough room. allocate a new overflow page.
|
||||
*/
|
||||
do_expand = true;
|
||||
ovflbuf = _hash_addovflpage(rel, &metabuf, buf);
|
||||
ovflbuf = _hash_addovflpage(rel, metabuf, buf);
|
||||
_hash_relbuf(rel, buf, HASH_WRITE);
|
||||
buf = ovflbuf;
|
||||
page = BufferGetPage(buf);
|
||||
@@ -186,18 +186,15 @@ _hash_insertonpg(Relation rel,
|
||||
* access type just for a moment to allow greater accessibility to
|
||||
* the metapage.
|
||||
*/
|
||||
metap = (HashMetaPage) _hash_chgbufaccess(rel, &metabuf,
|
||||
HASH_READ, HASH_WRITE);
|
||||
metap->hashm_nkeys += 1;
|
||||
metap = (HashMetaPage) _hash_chgbufaccess(rel, &metabuf,
|
||||
HASH_WRITE, HASH_READ);
|
||||
|
||||
_hash_chgbufaccess(rel, metabuf, HASH_READ, HASH_WRITE);
|
||||
metap->hashm_ntuples += 1;
|
||||
_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_READ);
|
||||
}
|
||||
|
||||
_hash_wrtbuf(rel, buf);
|
||||
|
||||
if (do_expand ||
|
||||
(metap->hashm_nkeys / (metap->hashm_maxbucket + 1))
|
||||
(metap->hashm_ntuples / (metap->hashm_maxbucket + 1))
|
||||
> metap->hashm_ffactor)
|
||||
_hash_expandtable(rel, metabuf);
|
||||
_hash_relbuf(rel, metabuf, HASH_READ);
|
||||
|
||||
Reference in New Issue
Block a user