Skip to content

Commit 65c2d42

Browse files
committed
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.
1 parent eaeb862 commit 65c2d42

File tree

4 files changed

+364
-450
lines changed

4 files changed

+364
-450
lines changed

src/backend/access/hash/hashinsert.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.27 2003/08/04 02:39:57 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.28 2003/09/01 20:26:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -155,7 +155,7 @@ _hash_insertonpg(Relation rel,
155155
* page with enough room. allocate a new overflow page.
156156
*/
157157
do_expand = true;
158-
ovflbuf = _hash_addovflpage(rel, &metabuf, buf);
158+
ovflbuf = _hash_addovflpage(rel, metabuf, buf);
159159
_hash_relbuf(rel, buf, HASH_WRITE);
160160
buf = ovflbuf;
161161
page = BufferGetPage(buf);
@@ -186,18 +186,15 @@ _hash_insertonpg(Relation rel,
186186
* access type just for a moment to allow greater accessibility to
187187
* the metapage.
188188
*/
189-
metap = (HashMetaPage) _hash_chgbufaccess(rel, &metabuf,
190-
HASH_READ, HASH_WRITE);
191-
metap->hashm_nkeys += 1;
192-
metap = (HashMetaPage) _hash_chgbufaccess(rel, &metabuf,
193-
HASH_WRITE, HASH_READ);
194-
189+
_hash_chgbufaccess(rel, metabuf, HASH_READ, HASH_WRITE);
190+
metap->hashm_ntuples += 1;
191+
_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_READ);
195192
}
196193

197194
_hash_wrtbuf(rel, buf);
198195

199196
if (do_expand ||
200-
(metap->hashm_nkeys / (metap->hashm_maxbucket + 1))
197+
(metap->hashm_ntuples / (metap->hashm_maxbucket + 1))
201198
> metap->hashm_ffactor)
202199
_hash_expandtable(rel, metabuf);
203200
_hash_relbuf(rel, metabuf, HASH_READ);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy