summaryrefslogtreecommitdiff
path: root/db2/hash
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-09-30 17:10:40 +0000
committerUlrich Drepper <drepper@redhat.com>1997-09-30 17:10:40 +0000
commita5a0310d8e9d7176bb17e91c916272006a871016 (patch)
treeb922b764878596e6ee42ae84cc315ecaaac00505 /db2/hash
parenta2b08ee54130cf3a74655856e6ca6c29874a9df2 (diff)
1997-09-30 18:03 Ulrich Drepper <drepper@cygnus.com> * Makerules: Undo last change. * csu/Makefile: Define before-compile at the right place. * aclocal.m4: Remove a.out file created by assembler test. * set-init.c: Find set-hooks.h using <...>. Update to db 2.3.10. * db2/Makefile: Update. * db2/db.h: Likewise. * db2/db_185.h: Likewise. * db2/db_int.h: Likewise. * db2/btree/bt_close.c: Likewise. * db2/btree/bt_conv.c: Likewise. * db2/btree/bt_cursor.c: Likewise. * db2/btree/bt_put.c: Likewise. * db2/btree/bt_rec.c: Likewise. * db2/btree/bt_recno.c: Likewise. * db2/btree/btree.src: Likewise. * db2/btree/btree_auto.c: Likewise. * db2/clib/getlong.c: Likewise. * db2/db/db.c: Likewise. * db2/db/db_auto.c: Likewise. * db2/db/db_conv.c: Likewise. * db2/db/db_pr.c: Likewise. * db2/db/db_ret.c: Likewise. * db2/db/db_thread.c: Likewise. * db2/hash/hash.c: Likewise. * db2/hash/hash_auto.c: Likewise. * db2/hash/hash_conv.c: Likewise. * db2/hash/hash_dup.c: Likewise. * db2/hash/hash_func.c: Likewise. * db2/hash/hash_page.c: Likewise. * db2/hash/hash_rec.c: Likewise. * db2/include/btree.h: Likewise. * db2/include/btree_ext.h: Likewise. * db2/include/db.h.src: Likewise. * db2/include/db_185.h.src: Likewise. * db2/include/db_cxx.h: Likewise. * db2/include/db_ext.h: Likewise. * db2/include/db_int.h.src: Likewise. * db2/include/db_page.h: Likewise. * db2/include/db_shash.h: Likewise. * db2/include/lock.h: Likewise. * db2/include/log.h: Likewise. * db2/include/log_ext.h: Likewise. * db2/include/mp.h: Likewise. * db2/include/shqueue.h: Likewise. * db2/include/txn.h: Likewise. * db2/lock/lock.c: Likewise. * db2/lock/lock_deadlock.c: Likewise. * db2/log/log.c: Likewise. * db2/log/log_archive.c: Likewise. * db2/log/log_auto.c: Likewise. * db2/log/log_get.c: Likewise. * db2/log/log_put.c: Likewise. * db2/log/log_register.c: Likewise. * db2/mp/mp_bh.c: Likewise. * db2/mp/mp_fget.c: Likewise. * db2/mp/mp_fopen.c: Likewise. * db2/mp/mp_fput.c: Likewise. * db2/mp/mp_fset.c: Likewise. * db2/mp/mp_open.c: Likewise. * db2/mutex/mutex.c: Likewise. * db2/os/db_os_dir.c: Likewise. * db2/progs/db_checkpoint/db_checkpoint.c: Likewise. * db2/progs/db_deadlock/db_deadlock.c: Likewise. * db2/progs/db_dump185/db_dump185.c: Likewise. * db2/progs/db_load/db_load.c: Likewise. * db2/progs/db_recover/db_recover.c: Likewise. * db2/txn/txn.c: Likewise. * db2/txn/txn_auto.c: Likewise. * elf/link.h: Define struct libname_list outside struct link_map to not confuse C++ compilers. * include/features.h: Recognize _XOPEN_SOURCE == 500 and set __USE_UNIX98. * manual/creature.texi: Explain this. * libc.map: Add new functions. * libio/Makefile (routines): Add fseeko and ftello. * libio/ftello.c: New file. * libio/fseeko.c: New file. * libio/stdio.h: Add prototypes for new functions. * manual/stdio.texi: Document fseeko and ftello. * posix/Makefile (routines): Add pread and pwrite. * sysdeps/posix/pread.c: New file. * sysdeps/posix/pwrite.c: New file. * sysdeps/stub/pread.c: New file. * sysdeps/stub/pwrite.c: New file. * posix/unistd.h: Add prototypes for pread and pwrite. Pretty print header. Define gid_t, uid_t, off_t, pid_t if __USE_UNIX98. Declare ctermid and cuserid if __USE_UNIX98. (swab): Change to take void * arguments. * string/swab.c: Change parameter to void *. * posix/sys/types: Define gid_t, uid_t, off_t, pid_t only if not already happened. * manual/llio.texi: Document pread and pwrite. * string/strings.h: Don't simply include string.h. Define BSD functions according to Unix98. * stdlib/tst-strtol.c: Include <string.h> not <strings.h>. * sunrpc/clnt_simp.c: Likewise. * malloc/Makefile (aux): Add set-freeres. * malloc/mtrace.c: Define function release_libc_mem which calls the __libc_subfreeres handler. (mtrace): Register release_libc_mem. * malloc/set-freeres.c: New file. * intl/dcgettext.c: Define free_mem function and add to __libc_subfreeres list. * intl/finddomain.c: Likewise. * intl/gettextP.h (struct loaded_domain): Add new fields use_mmap and mmap_size. Add prototype for _nl_unloaded_domain. * intl/loadmsgcat.c: Define new function _nl_unload_domain. (_nl_load_domain): Store informaiton about mmap use and file size. * intl/localealias.c (read_alias_file): Optimize locale alias file reading by avoid frequen mallocs. Define free_mem function and add to __libc_subfreeres list. * locale/localeinfo.h: Make a difference between MAX_USAGE_COUNT and undeletable. Add prototype for _nl_unload_locale. * locale/C-collate: Mark data as undeletable by using UNDELETABLE. * locale/C-ctype: Likewise. * locale/C-messages: Likewise. * locale/C-monetary: Likewise. * locale/C-numeric: Likewise. * locale/C-time: Likewise. * locale/findlocale.c (_nl_find_locale, _nl_remove_locale): Handle MAX_USAGE_COUNT and UNDELETABLE. (free_mem): New function. Add it to __libc_subfreeres list. * locale/loadlocale.c: Define _nl_unload_locale function. * misc/hsearch.c: Register hdestroy in __libc_subfreeres list. * stdlib/fmtmsg.c (addseverity): Handle illegal severity arguments correctly Define free_mem function and add to __libc_subfreeres list. * locale/programs/localedef.c (options): short form os verbose is v. Reported by Andreas Jaeger. * misc/sys/select.h: Define pselect only is __USE_POSIX since this header is used in some others as well for historical reasons. * resolv/resolv.h: Include <netinet/in.h> to make self-contained. * string/bits/string2.h: Add missing braces and optimize strcmp a bit more. * sysdeps/i386/i486/bits/string.h: Likewise. * sunrpc/rpc/auth_des.h: Include rpc/auth.h to be self-contained. Pretty print. * sysdeps/mach/hurd/cthreads.c: Add copyright text. * sysdeps/unix/sysv/linux/syscalls.list: Correct prctl entry. * sysdeps/unix/sysv/linux/sys/mman.h: Get definition of size_t. * time/time.h: Pretty print. 1997-09-29 Paul Eggert <eggert@twinsun.com> * time/strftime.c: Synchronize with GNU Emacs strftime.c. (HAVE_MEMCPY): Define if emacs is defined and HAVE_BCOPY isn't. (gmtime_r, localtime_r): Undef before defining. (iso_week_days): Use __inline__, not inline. 1997-09-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/fpu/bits/mathinline.h: Rename exp2{,l,f} to __ieee754_exp2{,l,f}. * sysdeps/m68k/fpu/s_exp2.c: Likewise. * sysdeps/m68k/fpu/s_exp2l.c: Likewise. * sysdeps/m68k/fpu/s_exp2f.c: Likewise. 1997-09-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/soinit.c (__EH_FRAME_BEGIN__): Don't make the .eh_frame section read-only, it contains relocations. * elf/sofini.c (__FRAME_END__): Likewise. 1997-09-29 03:08 Ulrich Drepper <drepper@cygnus.com> * sysdeps/i386/i486/bits/string.h [__PIC__] (__strspn_cg, __strcspn_cg, __strpbrk_cg, __strstr_cg): Optimize even more. No spill register needed. Patch by NIIBE Yutaka <gniibe@mri.co.jp>. 1997-09-28 08:27 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/nis_call.c (__do_niscall2): Fix return code, add missing break in switch case. * nis/nis_mkdir.c: Fix return codes to match Solaris version. * nis/nis_rmdir.c: Likewise. * nis/rpcsvc/yp_prot.h: Rename struct keydat to struct keydat_t for C++. 1997-09-28 04:32 Ulrich Drepper <drepper@cygnus.com> * configure.in: Fix typo. Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>. 1997-09-25 20:14 Philip Blundell <Philip.Blundell@pobox.com> * sysdeps/unix/sysv/linux/scsi/sg.h: New file. * sysdeps/unix/sysv/linux/Makefile: Install <scsi/sg.h>.
Diffstat (limited to 'db2/hash')
-rw-r--r--db2/hash/hash.c90
-rw-r--r--db2/hash/hash_auto.c14
-rw-r--r--db2/hash/hash_conv.c22
-rw-r--r--db2/hash/hash_dup.c49
-rw-r--r--db2/hash/hash_func.c6
-rw-r--r--db2/hash/hash_page.c69
-rw-r--r--db2/hash/hash_rec.c12
7 files changed, 143 insertions, 119 deletions
diff --git a/db2/hash/hash.c b/db2/hash/hash.c
index 6d8c40057d..d986e08087 100644
--- a/db2/hash/hash.c
+++ b/db2/hash/hash.c
@@ -47,7 +47,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)hash.c 10.25 (Sleepycat) 8/24/97";
+static const char sccsid[] = "@(#)hash.c 10.27 (Sleepycat) 9/15/97";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -573,8 +573,6 @@ __ham_c_close(cursor)
DBC *cursor;
{
DB *ldbp;
- HTAB *hashp;
- HASH_CURSOR *hcp;
int ret;
DEBUG_LWRITE(cursor->dbp, cursor->txn, "ham_c_close", NULL, NULL, 0);
@@ -590,8 +588,32 @@ __ham_c_close(cursor)
if (F_ISSET(cursor->dbp, DB_AM_THREAD) &&
(ret = __db_gethandle(cursor->dbp, __ham_hdup, &ldbp)) != 0)
return (ret);
- hashp = (HTAB *)ldbp->internal;
- hcp = (HASH_CURSOR *)cursor->internal;
+
+ ret = __ham_c_iclose(ldbp, cursor);
+
+ if (F_ISSET(ldbp, DB_AM_THREAD))
+ __db_puthandle(ldbp);
+ return (ret);
+}
+/*
+ * __ham_c_iclose --
+ *
+ * Internal cursor close routine; assumes it is being passed the correct
+ * handle, rather than getting and putting a handle.
+ *
+ * PUBLIC: int __ham_c_iclose __P((DB *, DBC *));
+ */
+int
+__ham_c_iclose(dbp, dbc)
+ DB *dbp;
+ DBC *dbc;
+{
+ HASH_CURSOR *hcp;
+ HTAB *hashp;
+ int ret;
+
+ hashp = (HTAB *)dbp->internal;
+ hcp = (HASH_CURSOR *)dbc->internal;
ret = __ham_item_done(hashp, hcp, 0);
if (hcp->big_key)
@@ -602,19 +624,16 @@ __ham_c_close(cursor)
/*
* All cursors (except the default ones) are linked off the master.
* Therefore, when we close the cursor, we have to remove it from
- * the master, not the local one. When we are closing the file in
- * its entirety, then we clear the THREAD bit and the master and
- * local are identical, so we remove the correct one.
+ * the master, not the local one.
+ * XXX I am always removing from the master; what about local cursors?
*/
- DB_THREAD_LOCK(cursor->dbp);
- TAILQ_REMOVE(&cursor->dbp->curs_queue, cursor, links);
- DB_THREAD_UNLOCK(cursor->dbp);
-
- if (F_ISSET(cursor->dbp, DB_AM_THREAD))
- __db_puthandle(ldbp);
+ DB_THREAD_LOCK(dbc->dbp);
+ TAILQ_REMOVE(&dbc->dbp->curs_queue, dbc, links);
+ DB_THREAD_UNLOCK(dbc->dbp);
FREE(hcp, sizeof(HASH_CURSOR));
- FREE(cursor, sizeof(DBC));
+ FREE(dbc, sizeof(DBC));
+
return (ret);
}
@@ -695,10 +714,9 @@ __ham_c_del(cursor, flags)
hcp->dndx = 0; /* Case 2 */
hcp->dpgno = PGNO(hcp->dpagep);
if (ppgno == PGNO_INVALID)
- memcpy(P_ENTRY(hcp->pagep,
- H_DATAINDEX(hcp->bndx)) +
- SSZ(HOFFDUP, pgno), &hcp->dpgno,
- sizeof(db_pgno_t));
+ memcpy(HOFFDUP_PGNO(P_ENTRY(hcp->pagep,
+ H_DATAINDEX(hcp->bndx))),
+ &hcp->dpgno, sizeof(db_pgno_t));
F_SET(hcp, H_DELETED);
} else /* Case 1 */
F_SET(hcp, H_DELETED);
@@ -1051,18 +1069,17 @@ __ham_dup_return(hashp, hcp, val, flags)
DBT *val;
int flags;
{
- HKEYDATA *hk;
PAGE *pp;
DBT *myval, tmp_val;
db_indx_t ndx;
db_pgno_t pgno;
- u_int8_t type;
+ u_int8_t *hk, type;
int indx, ret;
db_indx_t len;
/* Check for duplicate and return the first one. */
ndx = H_DATAINDEX(hcp->bndx);
- type = GET_HKEYDATA(hcp->pagep, ndx)->type;
+ type = HPAGE_TYPE(hcp->pagep, ndx);
pp = hcp->pagep;
myval = val;
@@ -1088,7 +1105,8 @@ __ham_dup_return(hashp, hcp, val, flags)
hcp->dndx = 0;
hcp->dup_off = 0;
do {
- memcpy(&len, hk->data + hcp->dup_off,
+ memcpy(&len,
+ HKEYDATA_DATA(hk) + hcp->dup_off,
sizeof(db_indx_t));
hcp->dup_off += DUP_SIZE(len);
hcp->dndx++;
@@ -1096,15 +1114,15 @@ __ham_dup_return(hashp, hcp, val, flags)
hcp->dup_off -= DUP_SIZE(len);
hcp->dndx--;
} else {
- memcpy(&len, hk->data, sizeof(db_indx_t));
+ memcpy(&len,
+ HKEYDATA_DATA(hk), sizeof(db_indx_t));
hcp->dup_off = 0;
hcp->dndx = 0;
}
hcp->dup_len = len;
} else if (type == H_OFFDUP) {
F_SET(hcp, H_ISDUP);
- memcpy(&pgno,
- P_ENTRY(hcp->pagep, ndx) + SSZ(HOFFDUP, pgno),
+ memcpy(&pgno, HOFFDUP_PGNO(P_ENTRY(hcp->pagep, ndx)),
sizeof(db_pgno_t));
if (flags == DB_LAST || flags == DB_PREV) {
indx = (int)hcp->dndx;
@@ -1166,7 +1184,7 @@ __ham_overwrite(hashp, hcp, nval)
DBT *nval;
{
DBT *myval, tmp_val;
- HKEYDATA *hk;
+ u_int8_t *hk;
if (F_ISSET(hashp->dbp, DB_AM_DUP))
return (__ham_add_dup(hashp, hcp, nval, DB_KEYLAST));
@@ -1176,10 +1194,9 @@ __ham_overwrite(hashp, hcp, nval)
F_SET(&tmp_val, DB_DBT_PARTIAL);
tmp_val.doff = 0;
hk = H_PAIRDATA(hcp->pagep, hcp->bndx);
- if (hk->type == H_OFFPAGE)
+ if (HPAGE_PTYPE(hk) == H_OFFPAGE)
memcpy(&tmp_val.dlen,
- (u_int8_t *)hk + SSZ(HOFFPAGE, tlen),
- sizeof(u_int32_t));
+ HOFFPAGE_TLEN(hk), sizeof(u_int32_t));
else
tmp_val.dlen = LEN_HDATA(hcp->pagep,
hashp->hdr->pagesize,hcp->bndx);
@@ -1207,10 +1224,10 @@ __ham_lookup(hashp, hcp, key, sought, mode)
u_int32_t sought;
db_lockmode_t mode;
{
- HKEYDATA *hk;
db_pgno_t pgno;
u_int32_t tlen;
int match, ret, t_ret;
+ u_int8_t *hk;
/*
* Set up cursor so that we're looking for space to add an item
@@ -1229,14 +1246,12 @@ __ham_lookup(hashp, hcp, key, sought, mode)
break;
hk = H_PAIRKEY(hcp->pagep, hcp->bndx);
- switch (hk->type) {
+ switch (HPAGE_PTYPE(hk)) {
case H_OFFPAGE:
- memcpy(&tlen, (u_int8_t *)hk + SSZ(HOFFPAGE, tlen),
- sizeof(u_int32_t));
+ memcpy(&tlen, HOFFPAGE_TLEN(hk), sizeof(u_int32_t));
if (tlen == key->size) {
memcpy(&pgno,
- (u_int8_t *)hk + SSZ(HOFFPAGE, pgno),
- sizeof(db_pgno_t));
+ HOFFPAGE_PGNO(hk), sizeof(db_pgno_t));
match = __db_moff(hashp->dbp, key, pgno);
if (match == 0) {
F_SET(hcp, H_OK);
@@ -1247,7 +1262,8 @@ __ham_lookup(hashp, hcp, key, sought, mode)
case H_KEYDATA:
if (key->size == LEN_HKEY(hcp->pagep,
hashp->hdr->pagesize, hcp->bndx) &&
- memcmp(key->data, hk->data, key->size) == 0) {
+ memcmp(key->data,
+ HKEYDATA_DATA(hk), key->size) == 0) {
F_SET(hcp, H_OK);
return (0);
}
diff --git a/db2/hash/hash_auto.c b/db2/hash/hash_auto.c
index f8ab80c8ee..2279de9668 100644
--- a/db2/hash/hash_auto.c
+++ b/db2/hash/hash_auto.c
@@ -138,7 +138,7 @@ __ham_insdel_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_insdel_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_insdel_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_insdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
@@ -335,7 +335,7 @@ __ham_newpage_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_newpage_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_newpage_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_newpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
@@ -498,7 +498,7 @@ __ham_splitmeta_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_splitmeta_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_splitmeta_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_splitmeta: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
@@ -659,7 +659,7 @@ __ham_splitdata_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_splitdata_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_splitdata_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_splitdata: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
@@ -851,7 +851,7 @@ __ham_replace_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_replace_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_replace_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_replace: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
@@ -1053,7 +1053,7 @@ __ham_newpgno_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_newpgno_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_newpgno_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_newpgno: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
@@ -1218,7 +1218,7 @@ __ham_ovfl_print(notused1, dbtp, lsnp, notused3, notused4)
notused3 = 0;
notused4 = NULL;
- if((ret = __ham_ovfl_read(dbtp->data, &argp)) != 0)
+ if ((ret = __ham_ovfl_read(dbtp->data, &argp)) != 0)
return (ret);
printf("[%lu][%lu]ham_ovfl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
(u_long)lsnp->file,
diff --git a/db2/hash/hash_conv.c b/db2/hash/hash_conv.c
index 22901af950..9cebe72390 100644
--- a/db2/hash/hash_conv.c
+++ b/db2/hash/hash_conv.c
@@ -7,7 +7,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)hash_conv.c 10.3 (Sleepycat) 6/21/97";
+static const char sccsid[] = "@(#)hash_conv.c 10.4 (Sleepycat) 9/15/97";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -20,12 +20,11 @@ static const char sccsid[] = "@(#)hash_conv.c 10.3 (Sleepycat) 6/21/97";
#include "hash.h"
/*
- * __h_pgin, __ham_pgout --
- * Convert host-specific page layout to/from the host-independent
- * format stored on disk.
+ * __ham_pgin --
+ * Convert host-specific page layout from the host-independent format
+ * stored on disk.
*
* PUBLIC: int __ham_pgin __P((db_pgno_t, void *, DBT *));
- * PUBLIC: int __ham_pgout __P((db_pgno_t, void *, DBT *));
*/
int
__ham_pgin(pg, pp, cookie)
@@ -49,9 +48,17 @@ __ham_pgin(pg, pp, cookie)
if (!pginfo->needswap)
return (0);
- return (pg == PGNO_METADATA ? __ham_mswap(pp) : __db_pgin(pg, pp));
+ return (pg == PGNO_METADATA ?
+ __ham_mswap(pp) : __db_pgin(pg, pginfo->db_pagesize, pp));
}
+/*
+ * __ham_pgout --
+ * Convert host-specific page layout to the host-independent format
+ * stored on disk.
+ *
+ * PUBLIC: int __ham_pgout __P((db_pgno_t, void *, DBT *));
+ */
int
__ham_pgout(pg, pp, cookie)
db_pgno_t pg;
@@ -63,7 +70,8 @@ __ham_pgout(pg, pp, cookie)
pginfo = (DB_PGINFO *)cookie->data;
if (!pginfo->needswap)
return (0);
- return (pg == PGNO_METADATA ? __ham_mswap(pp) : __db_pgout(pg, pp));
+ return (pg == PGNO_METADATA ?
+ __ham_mswap(pp) : __db_pgout(pg, pginfo->db_pagesize, pp));
}
/*
diff --git a/db2/hash/hash_dup.c b/db2/hash/hash_dup.c
index c9590fa49d..71bd1c5eb0 100644
--- a/db2/hash/hash_dup.c
+++ b/db2/hash/hash_dup.c
@@ -42,7 +42,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)hash_dup.c 10.6 (Sleepycat) 9/3/97";
+static const char sccsid[] = "@(#)hash_dup.c 10.7 (Sleepycat) 9/15/97";
#endif /* not lint */
/*
@@ -99,9 +99,9 @@ __ham_add_dup(hashp, hcp, nval, flags)
int flags;
{
DBT pval, tmp_val;
- HKEYDATA *hk;
u_int32_t del_len, new_size;
int ret;
+ u_int8_t *hk;
if (flags == DB_CURRENT && hcp->dpgno == PGNO_INVALID)
del_len = hcp->dup_len;
@@ -128,8 +128,8 @@ __ham_add_dup(hashp, hcp, nval, flags)
* the addition of the new item will make the set large, or
* if there isn't enough room on this page to add the next item.
*/
- if (hk->type != H_OFFDUP &&
- (hk->type == H_OFFPAGE || ISBIG(hashp, new_size) ||
+ if (HPAGE_PTYPE(hk) != H_OFFDUP &&
+ (HPAGE_PTYPE(hk) == H_OFFPAGE || ISBIG(hashp, new_size) ||
DUP_SIZE(nval->size) - del_len > P_FREESPACE(hcp->pagep))) {
if ((ret = __ham_dup_convert(hashp, hcp)) != 0)
@@ -139,16 +139,17 @@ __ham_add_dup(hashp, hcp, nval, flags)
}
/* There are two separate cases here: on page and off page. */
- if (hk->type != H_OFFDUP) {
- if (hk->type != H_DUPLICATE) {
- hk->type = H_DUPLICATE;
+ if (HPAGE_PTYPE(hk) != H_OFFDUP) {
+ if (HPAGE_PTYPE(hk) != H_DUPLICATE) {
+ HPAGE_PTYPE(hk) = H_DUPLICATE;
pval.flags = 0;
- pval.data = hk->data;
+ pval.data = HKEYDATA_DATA(hk);
pval.size = LEN_HDATA(hcp->pagep, hashp->hdr->pagesize,
hcp->bndx);
- if ((ret = __ham_make_dup(&pval, &tmp_val, &hcp->big_data,
- &hcp->big_datalen)) != 0 ||
- (ret = __ham_replpair(hashp, hcp, &tmp_val, 1)) != 0)
+ if ((ret =
+ __ham_make_dup(&pval, &tmp_val, &hcp->big_data,
+ &hcp->big_datalen)) != 0 || (ret =
+ __ham_replpair(hashp, hcp, &tmp_val, 1)) != 0)
return (ret);
}
@@ -187,8 +188,7 @@ __ham_add_dup(hashp, hcp, nval, flags)
/* If we get here, then we're on duplicate pages. */
if (hcp->dpgno == PGNO_INVALID) {
- memcpy(&hcp->dpgno,
- (u_int8_t *)hk + SSZ(HOFFDUP, pgno), sizeof(db_pgno_t));
+ memcpy(&hcp->dpgno, HOFFDUP_PGNO(hk), sizeof(db_pgno_t));
hcp->dndx = 0;
}
@@ -259,14 +259,13 @@ __ham_dup_convert(hashp, hcp)
* Now put the duplicates onto the new page.
*/
dbt.flags = 0;
- switch (((HKEYDATA *)H_PAIRDATA(hcp->pagep, hcp->bndx))->type) {
+ switch (HPAGE_PTYPE(H_PAIRDATA(hcp->pagep, hcp->bndx))) {
case H_KEYDATA:
/* Simple case, one key on page; move it to dup page. */
dndx = 0;
dbt.size =
LEN_HDATA(hcp->pagep, hashp->hdr->pagesize, hcp->bndx);
- dbt.data =
- ((HKEYDATA *)H_PAIRDATA(hcp->pagep, hcp->bndx))->data;
+ dbt.data = HKEYDATA_DATA(H_PAIRDATA(hcp->pagep, hcp->bndx));
ret = __db_pitem(hashp->dbp, hcp->dpagep,
(u_int32_t)dndx, BKEYDATA_SIZE(dbt.size), NULL, &dbt);
if (ret == 0)
@@ -289,7 +288,7 @@ __ham_dup_convert(hashp, hcp)
__ham_dirty_page(hashp, hcp->dpagep);
break;
case H_DUPLICATE:
- p = ((HKEYDATA *)H_PAIRDATA(hcp->pagep, hcp->bndx))->data;
+ p = HKEYDATA_DATA(H_PAIRDATA(hcp->pagep, hcp->bndx));
pend = p +
LEN_HDATA(hcp->pagep, hashp->hdr->pagesize, hcp->bndx);
@@ -366,24 +365,23 @@ __ham_check_move(hashp, hcp, add_len)
{
DBT k, d;
DB_LSN new_lsn;
- HKEYDATA *hk;
PAGE *next_pagep;
db_pgno_t next_pgno;
int rectype, ret;
u_int32_t new_datalen, old_len;
+ u_int8_t *hk;
/*
* Check if we can do whatever we need to on this page. If not,
* then we'll have to move the current element to a new page.
*/
-
hk = H_PAIRDATA(hcp->pagep, hcp->bndx);
/*
* If the item is already off page duplicates or an offpage item,
* then we know we can do whatever we need to do in-place
*/
- if (hk->type == H_OFFDUP || hk->type == H_OFFPAGE)
+ if (HPAGE_PTYPE(hk) == H_OFFDUP || HPAGE_PTYPE(hk) == H_OFFPAGE)
return (0);
old_len =
@@ -443,22 +441,25 @@ __ham_check_move(hashp, hcp, add_len)
rectype = PUTPAIR;
k.flags = 0;
d.flags = 0;
- if (H_PAIRKEY(hcp->pagep, hcp->bndx)->type == H_OFFPAGE) {
+ if (HPAGE_PTYPE(
+ H_PAIRKEY(hcp->pagep, hcp->bndx)) == H_OFFPAGE) {
rectype |= PAIR_KEYMASK;
k.data = H_PAIRKEY(hcp->pagep, hcp->bndx);
k.size = HOFFPAGE_SIZE;
} else {
- k.data = H_PAIRKEY(hcp->pagep, hcp->bndx)->data;
+ k.data =
+ HKEYDATA_DATA(H_PAIRKEY(hcp->pagep, hcp->bndx));
k.size = LEN_HKEY(hcp->pagep,
hashp->hdr->pagesize, hcp->bndx);
}
- if (hk->type == H_OFFPAGE) {
+ if (HPAGE_PTYPE(hk) == H_OFFPAGE) {
rectype |= PAIR_DATAMASK;
d.data = H_PAIRDATA(hcp->pagep, hcp->bndx);
d.size = HOFFPAGE_SIZE;
} else {
- d.data = H_PAIRDATA(hcp->pagep, hcp->bndx)->data;
+ d.data =
+ HKEYDATA_DATA(H_PAIRDATA(hcp->pagep, hcp->bndx));
d.size = LEN_HDATA(hcp->pagep,
hashp->hdr->pagesize, hcp->bndx);
}
diff --git a/db2/hash/hash_func.c b/db2/hash/hash_func.c
index 2ef47afb57..1bf12c4948 100644
--- a/db2/hash/hash_func.c
+++ b/db2/hash/hash_func.c
@@ -47,7 +47,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)hash_func.c 10.6 (Sleepycat) 7/26/97";
+static const char sccsid[] = "@(#)hash_func.c 10.7 (Sleepycat) 9/16/97";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -64,7 +64,7 @@ static const char sccsid[] = "@(#)hash_func.c 10.6 (Sleepycat) 7/26/97";
*
* PUBLIC: u_int32_t __ham_func2 __P((const void *, u_int32_t));
*/
-#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
+#define DCHARHASH(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
u_int32_t
__ham_func2(key, len)
@@ -81,7 +81,7 @@ __ham_func2(key, len)
c = *k++;
if (!c && k > e)
break;
- dcharhash(h, c);
+ DCHARHASH(h, c);
}
return (h);
}
diff --git a/db2/hash/hash_page.c b/db2/hash/hash_page.c
index 68c31b14f9..8ba42da1a4 100644
--- a/db2/hash/hash_page.c
+++ b/db2/hash/hash_page.c
@@ -47,10 +47,9 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)hash_page.c 10.18 (Sleepycat) 8/21/97";
+static const char sccsid[] = "@(#)hash_page.c 10.24 (Sleepycat) 9/17/97";
#endif /* not lint */
-
/*
* PACKAGE: hashing
*
@@ -85,7 +84,7 @@ static const char sccsid[] = "@(#)hash_page.c 10.18 (Sleepycat) 8/21/97";
static int __ham_lock_bucket __P((DB *, HASH_CURSOR *, db_lockmode_t));
#ifdef DEBUG_SLOW
-static void account_page(HTAB *, db_pgno_t, int);
+static void __account_page(HTAB *, db_pgno_t, int);
#endif
/*
@@ -121,7 +120,7 @@ __ham_item(hashp, cursorp, mode)
* pointer to be the beginning of the datum.
*/
memcpy(&cursorp->dup_len,
- H_PAIRDATA(cursorp->pagep, cursorp->bndx)->data +
+ HKEYDATA_DATA(H_PAIRDATA(cursorp->pagep, cursorp->bndx)) +
cursorp->dup_off, sizeof(db_indx_t));
else if (F_ISSET(cursorp, H_ISDUP)) {
/* Make sure we're not about to run off the page. */
@@ -326,8 +325,8 @@ __ham_item_prev(hashp, cursorp, mode)
else {
HASH_CURSOR *h;
h = cursorp;
- memcpy(&h->dup_len,
- H_PAIRDATA(h->pagep, h->bndx)->data
+ memcpy(&h->dup_len, HKEYDATA_DATA(
+ H_PAIRDATA(h->pagep, h->bndx))
+ h->dup_off - sizeof(db_indx_t),
sizeof(db_indx_t));
cursorp->dup_off -=
@@ -481,7 +480,7 @@ __ham_putitem(p, dbt, type)
} else {
off = HOFFSET(p) - HKEYDATA_SIZE(dbt->size);
HOFFSET(p) = p->inp[n] = off;
- PUT_HKEYDATA(GET_HKEYDATA(p, n), dbt->data, dbt->size, type);
+ PUT_HKEYDATA(P_ENTRY(p, n), dbt->data, dbt->size, type);
}
/* Adjust page info. */
@@ -524,24 +523,24 @@ __ham_del_pair(hashp, cursorp)
* entry referring to the big item.
*/
ret = 0;
- if (H_PAIRKEY(p, ndx)->type == H_OFFPAGE) {
- memcpy(&pgno, (u_int8_t *)GET_HOFFPAGE(p, H_KEYINDEX(ndx)) +
- SSZ(HOFFPAGE, pgno), sizeof(db_pgno_t));
+ if (HPAGE_PTYPE(H_PAIRKEY(p, ndx)) == H_OFFPAGE) {
+ memcpy(&pgno, HOFFPAGE_PGNO(P_ENTRY(p, H_KEYINDEX(ndx))),
+ sizeof(db_pgno_t));
ret = __db_doff(hashp->dbp, pgno, __ham_del_page);
}
if (ret == 0)
- switch (H_PAIRDATA(p, ndx)->type) {
+ switch (HPAGE_PTYPE(H_PAIRDATA(p, ndx))) {
case H_OFFPAGE:
memcpy(&pgno,
- (u_int8_t *)GET_HOFFPAGE(p, H_DATAINDEX(ndx)) +
- SSZ(HOFFPAGE, pgno), sizeof(db_pgno_t));
+ HOFFPAGE_PGNO(P_ENTRY(p, H_DATAINDEX(ndx))),
+ sizeof(db_pgno_t));
ret = __db_doff(hashp->dbp, pgno, __ham_del_page);
break;
case H_OFFDUP:
memcpy(&pgno,
- (u_int8_t *)GET_HOFFDUP(p, H_DATAINDEX(ndx)) +
- SSZ(HOFFDUP, pgno), sizeof(db_pgno_t));
+ HOFFDUP_PGNO(P_ENTRY(p, H_DATAINDEX(ndx))),
+ sizeof(db_pgno_t));
ret = __db_ddup(hashp->dbp, pgno, __ham_del_page);
break;
}
@@ -706,13 +705,12 @@ __ham_replpair(hashp, hcp, dbt, make_dup)
DBT *dbt;
u_int32_t make_dup;
{
- DBT old_dbt, tmp;
+ DBT old_dbt, tdata, tmp;
DB_LSN new_lsn;
- HKEYDATA *hk;
u_int32_t len;
int32_t change;
int is_big, ret, type;
- u_int8_t *beg, *dest, *end, *src;
+ u_int8_t *beg, *dest, *end, *hk, *src;
/*
* Big item replacements are handled in generic code.
@@ -738,11 +736,10 @@ __ham_replpair(hashp, hcp, dbt, make_dup)
change = dbt->size - dbt->dlen;
hk = H_PAIRDATA(hcp->pagep, hcp->bndx);
- is_big = hk->type == H_OFFPAGE;
+ is_big = HPAGE_PTYPE(hk) == H_OFFPAGE;
if (is_big)
- memcpy(&len, (u_int8_t *)hk + SSZ(HOFFPAGE, tlen),
- sizeof(u_int32_t));
+ memcpy(&len, HOFFPAGE_TLEN(hk), sizeof(u_int32_t));
else
len = LEN_HKEYDATA(hcp->pagep,
hashp->dbp->pgsize, H_DATAINDEX(hcp->bndx));
@@ -770,13 +767,14 @@ __ham_replpair(hashp, hcp, dbt, make_dup)
&tmp, &hcp->big_key, &hcp->big_keylen)) != 0)
return (ret);
- type = hk->type;
if (dbt->doff == 0 && dbt->dlen == len) {
ret = __ham_del_pair(hashp, hcp);
if (ret == 0)
- ret = __ham_add_el(hashp, hcp, &tmp, dbt, type);
+ ret = __ham_add_el(hashp,
+ hcp, &tmp, dbt, H_KEYDATA);
} else { /* Case B */
- DBT tdata;
+ type = HPAGE_PTYPE(hk) != H_OFFPAGE ?
+ HPAGE_PTYPE(hk) : H_KEYDATA;
tdata.flags = 0;
F_SET(&tdata, DB_DBT_MALLOC | DB_DBT_INTERNAL);
@@ -824,7 +822,7 @@ err: free(tmp.data);
* Set up pointer into existing data. Do it before the log
* message so we can use it inside of the log setup.
*/
- beg = H_PAIRDATA(hcp->pagep, hcp->bndx)->data;
+ beg = HKEYDATA_DATA(H_PAIRDATA(hcp->pagep, hcp->bndx));
beg += dbt->doff;
/*
@@ -885,11 +883,11 @@ __ham_onpage_replace(pagep, pgsize, ndx, off, change, dbt)
if (off < 0)
len = pagep->inp[ndx] - HOFFSET(pagep);
else if ((u_int32_t)off >= LEN_HKEYDATA(pagep, pgsize, ndx)) {
- len = GET_HKEYDATA(pagep, ndx)->data +
+ len = HKEYDATA_DATA(P_ENTRY(pagep, ndx)) +
LEN_HKEYDATA(pagep, pgsize, ndx) - src;
zero_me = 1;
} else
- len = (GET_HKEYDATA(pagep, ndx)->data + off) - src;
+ len = (HKEYDATA_DATA(P_ENTRY(pagep, ndx)) + off) - src;
dest = src - change;
memmove(dest, src, len);
if (zero_me)
@@ -901,7 +899,7 @@ __ham_onpage_replace(pagep, pgsize, ndx, off, change, dbt)
HOFFSET(pagep) -= change;
}
if (off >= 0)
- memcpy(GET_HKEYDATA(pagep, ndx)->data + off,
+ memcpy(HKEYDATA_DATA(P_ENTRY(pagep, ndx)) + off,
dbt->data, dbt->size);
else
memcpy(P_ENTRY(pagep, ndx), dbt->data, dbt->size);
@@ -1319,7 +1317,7 @@ __ham_new_page(hashp, addr, type, pp)
return (ret);
#ifdef DEBUG_SLOW
- account_page(hashp, addr, 1);
+ __account_page(hashp, addr, 1);
#endif
/* This should not be necessary because page-in should do it. */
P_INIT(pagep,
@@ -1398,7 +1396,7 @@ __ham_put_page(dbp, pagep, is_dirty)
int32_t is_dirty;
{
#ifdef DEBUG_SLOW
- account_page((HTAB *)dbp->cookie,
+ __account_page((HTAB *)dbp->cookie,
((BKT *)((char *)pagep - sizeof(BKT)))->pgno, -1);
#endif
return (memp_fput(dbp->mpf, pagep, (is_dirty ? DB_MPOOL_DIRTY : 0)));
@@ -1432,7 +1430,7 @@ __ham_get_page(dbp, addr, pagep)
ret = memp_fget(dbp->mpf, &addr, DB_MPOOL_CREATE, pagep);
#ifdef DEBUG_SLOW
if (*pagep != NULL)
- account_page((HTAB *)dbp->internal, addr, 1);
+ __account_page((HTAB *)dbp->internal, addr, 1);
#endif
return (ret);
}
@@ -1523,11 +1521,11 @@ __ham_overflow_page(dbp, type, pp)
#ifdef DEBUG
/*
* PUBLIC: #ifdef DEBUG
- * PUBLIC: int bucket_to_page __P((HTAB *, int));
+ * PUBLIC: int __bucket_to_page __P((HTAB *, int));
* PUBLIC: #endif
*/
int
-bucket_to_page(hashp, n)
+__bucket_to_page(hashp, n)
HTAB *hashp;
int n;
{
@@ -1735,7 +1733,7 @@ __ham_dpair(dbp, p, pndx)
#ifdef DEBUG_SLOW
static void
-account_page(hashp, pgno, inout)
+__account_page(hashp, pgno, inout)
HTAB *hashp;
db_pgno_t pgno;
int inout;
@@ -1767,7 +1765,8 @@ account_page(hashp, pgno, inout)
last--;
}
for (i = 0; i < last; i++, list[i].times++)
- if (list[i].times > 20 && !is_bitmap_pgno(hashp, list[i].pgno))
+ if (list[i].times > 20 &&
+ !__is_bitmap_pgno(hashp, list[i].pgno))
(void)fprintf(stderr,
"Warning: pg %lu has been out for %d times\n",
(u_long)list[i].pgno, list[i].times);
diff --git a/db2/hash/hash_rec.c b/db2/hash/hash_rec.c
index 81d9bb5ea8..1b30be337d 100644
--- a/db2/hash/hash_rec.c
+++ b/db2/hash/hash_rec.c
@@ -47,7 +47,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)hash_rec.c 10.12 (Sleepycat) 8/22/97";
+static const char sccsid[] = "@(#)hash_rec.c 10.13 (Sleepycat) 9/15/97";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -364,11 +364,11 @@ __ham_replace_recover(logp, dbtp, lsnp, redo, info)
DB *mdbp, *file_dbp;
DB_MPOOLFILE *mpf;
DBT dbt;
- HKEYDATA *hk;
HTAB *hashp;
PAGE *pagep;
int32_t grow;
int change, cmp_n, cmp_p, getmeta, ret;
+ u_int8_t *hk;
getmeta = 0;
hashp = NULL; /* XXX: shut the compiler up. */
@@ -421,11 +421,11 @@ __ham_replace_recover(logp, dbtp, lsnp, redo, info)
__ham_onpage_replace(pagep,
file_dbp->pgsize, argp->ndx, argp->off, grow, &dbt);
if (argp->makedup) {
- hk = GET_HKEYDATA(pagep, argp->ndx);
+ hk = P_ENTRY(pagep, argp->ndx);
if (redo)
- hk->type = H_DUPLICATE;
+ HPAGE_PTYPE(hk) = H_DUPLICATE;
else
- hk->type = H_KEYDATA;
+ HPAGE_PTYPE(hk) = H_KEYDATA;
}
}
@@ -738,7 +738,7 @@ __ham_ovfl_recover(logp, dbtp, lsnp, redo, info)
DBT *dbtp;
DB_LSN *lsnp;
int redo;
- void *info;
+ void *info;
{
__ham_ovfl_args *argp;
DB *mdbp, *file_dbp;