about summary refs log tree commit diff
path: root/db2/hash
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-09 15:16:55 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-09 15:16:55 +0000
commitbf7997b65c7887d2acda95f5201d818a19d81711 (patch)
treeda3583de3a0b5892f90a4b1eb773a87b554ae37e /db2/hash
parent7646e67e6cc4c738a7b402c60fed39d52db0433b (diff)
downloadglibc-bf7997b65c7887d2acda95f5201d818a19d81711.tar.gz
glibc-bf7997b65c7887d2acda95f5201d818a19d81711.tar.xz
glibc-bf7997b65c7887d2acda95f5201d818a19d81711.zip
Update.
1998-06-09  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/linux/netinet/ip.h (struct ip_options): Define
	__data member only for gcc.  Reported by ak@muc.de.

	* misc/mntent.h: Undo last patch.
	* sysdeps/unix/sysv/linux/fstatvfs.c (fstatvfs): Undo last patch.
	* misc/tst/mntent.c: Adjust code for this change.

	* io/fts.c: Updated from a slightly more recent BSD version.
	* io/fts.h: Likewise.

	* libc.map: Add __libc_stack_end.

	* db2/Makefile (routines): Add lock_region.
	* db2/config.h: Update from db-2.4.14.
	* db2/db.h: Likewise.
	* db2/db_185.h: Likewise.
	* db2/db_int.h: Likewise.
	* db2/bt_close.c: Likewise.
	* db2/bt_compare.c: Likewise.
	* db2/bt_conv.c: Likewise.
	* db2/bt_cursor.c: Likewise.
	* db2/bt_delete.c: Likewise.
	* db2/bt_open.c: Likewise.
	* db2/bt_page.c: Likewise.
	* db2/bt_put.c: Likewise.
	* db2/bt_rec.c: Likewise.
	* db2/bt_recno.c: Likewise.
	* db2/bt_rsearch.c: Likewise.
	* db2/bt_search.c: Likewise.
	* db2/bt_split.c: Likewise.
	* db2/bt_stat.c: Likewise.
	* db2/btree.src: Likewise.
	* db2/btree_auto.c: Likewise.
	* db2/getlong.c: Likewise.
	* db2/db_appinit.c: Likewise.
	* db2/db_apprec.c: Likewise.
	* db2/db_byteorder.c: Likewise.
	* db2/db_err.c: Likewise.
	* db2/db_log2.c: Likewise.
	* db2/db_region.c: Likewise.
	* db2/db_salloc.c: Likewise.
	* db2/db_shash.c: Likewise.
	* db2/db.c: Likewise.
	* db2/db.src: Likewise.
	* db2/db_auto.c: Likewise.
	* db2/db_conv.c: Likewise.
	* db2/db_dispatch.c: Likewise.
	* db2/db_dup.c: Likewise.
	* db2/db_overflow.c: Likewise.
	* db2/db_pr.c: Likewise.
	* db2/db_rec.c: Likewise.
	* db2/db_ret.c: Likewise.
	* db2/db_thread.c: Likewise.
	* db2/db185.c: Likewise.
	* db2/db185_int.h: Likewise.
	* db2/dbm.c: Likewise.
	* db2/hash.c: Likewise.
	* db2/hash.src: Likewise.
	* db2/hash_auto.c: Likewise.
	* db2/hash_conv.c: Likewise.
	* db2/hash_debug.c: Likewise.
	* db2/hash_dup.c: Likewise.
	* db2/hash_func.c: Likewise.
	* db2/hash_page.c: Likewise.
	* db2/hash_rec.c: Likewise.
	* db2/hash_stat.c: Likewise.
	* db2/btree.h: Likewise.
	* db2/btree_ext.h: Likewise.
	* db2/clib_ext.h: Likewise.
	* db2/common_ext.h: Likewise.
	* db2/cxx_int.h: Likewise.
	* db2/db.h.src: Likewise.
	* db2/db_185.h.src: Likewise.
	* db2/db_am.h: Likewise.
	* db2/db_auto.h: Likewise.
	* db2/db_cxx.h: Likewise.
	* db2/db_dispatch.h: Likewise.
	* db2/db_ext.h: Likewise.
	* db2/db_int.h.src: Likewise.
	* db2/db_page.h: Likewise.
	* db2/db_shash.h: Likewise.
	* db2/db_swap.h: Likewise.
	* db2/hash.h: Likewise.
	* db2/hash_ext.h: Likewise.
	* db2/lock.h: Likewise.
	* db2/lock_ext.h: Likewise.
	* db2/log.h: Likewise.
	* db2/log_ext.h: Likewise.
	* db2/mp.h: Likewise.
	* db2/mp_ext.h: Likewise.
	* db2/mutex_ext.h: Likewise.
	* db2/os_ext.h: Likewise.
	* db2/os_func.h: Likewise.
	* db2/queue.h: Likewise.
	* db2/shqueue.h: Likewise.
	* db2/txn.h: Likewise.
	* db2/lock.c: Likewise.
	* db2/lock_conflict.c: Likewise.
	* db2/lock_deadlock.c: Likewise.
	* db2/lock_region.c: Likewise.
	* db2/lock_util.c: Likewise.
	* db2/log.c: Likewise.
	* db2/log.src: Likewise.
	* db2/log_archive.c: Likewise.
	* db2/log_auto.c: Likewise.
	* db2/log_compare.c: Likewise.
	* db2/log_findckp.c: Likewise.
	* db2/log_get.c: Likewise.
	* db2/log_put.c: Likewise.
	* db2/log_rec.c: Likewise.
	* db2/log_register.c: Likewise.
	* db2/mp_bh.c: Likewise.
	* db2/mp_fget.c: Likewise.
	* db2/mp_fopen.c: Likewise.
	* db2/mp_fput.c: Likewise.
	* db2/mp_fset.c: Likewise.
	* db2/mp_open.c: Likewise.
	* db2/mp_pr.c: Likewise.
	* db2/mp_region.c: Likewise.
	* db2/mp_sync.c: Likewise.
	* db2/68020.gcc: Likewise.
	* db2/mutex.c: Likewise.
	* db2/parisc.gcc: Likewise.
	* db2/parisc.hp: Likewise.
	* db2/sco.cc: Likewise.
	* db2/os_abs.c: Likewise.
	* db2/os_alloc.c: Likewise.
	* db2/os_config.c: Likewise.
	* db2/os_dir.c: Likewise.
	* db2/os_fid.c: Likewise.
	* db2/os_fsync.c: Likewise.
	* db2/os_map.c: Likewise.
	* db2/os_oflags.c: Likewise.
	* db2/os_open.c: Likewise.
	* db2/os_rpath.c: Likewise.
	* db2/os_rw.c: Likewise.
	* db2/os_seek.c: Likewise.
	* db2/os_sleep.c: Likewise.
	* db2/os_spin.c: Likewise.
	* db2/os_stat.c: Likewise.
	* db2/os_unlink.c: Likewise.
	* db2/db_archive.c: Likewise.
	* db2/db_checkpoint.c: Likewise.
	* db2/db_deadlock.c: Likewise.
	* db2/db_dump.c: Likewise.
	* db2/db_dump185.c: Likewise.
	* db2/db_load.c: Likewise.
	* db2/db_printlog.c: Likewise.
	* db2/db_recover.c: Likewise.
	* db2/db_stat.c: Likewise.
	* db2/txn.c: Likewise.
	* db2/txn.src: Likewise.
	* db2/txn_auto.c: Likewise.
	* db2/txn_rec.c: Likewise.

	* elf/rtld.c: Move definition of __libc_stack_end to ...
	* sysdeps/generic/dl-sysdep.h: ...here.

	* sysdeps/unix/sysv/linux/fstatvfs.c: Handle nodiratime option.
	* sysdeps/unix/sysv/linux/bits/statvfs.h: Define ST_NODIRATIME.
	* sysdeps/unix/sysv/linux/sys/mount.h: Define MS_NODIRATIME.

1998-06-08 21:44  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/linux/fstatvfs.c: Handle constant option string
	from mntent correctly.

1998-06-06  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sunrpc/Makefile (generated): Correct typo.

1998-06-04  Philip Blundell  <philb@gnu.org>

	* elf/elf.h (EM_ARM, et al.): New definitions.
	* sysdeps/arm/dl-machine.h: Update for new draft ARM ELF ABI.
Diffstat (limited to 'db2/hash')
-rw-r--r--db2/hash/hash.c92
-rw-r--r--db2/hash/hash.src6
-rw-r--r--db2/hash/hash_auto.c186
-rw-r--r--db2/hash/hash_conv.c4
-rw-r--r--db2/hash/hash_debug.c10
-rw-r--r--db2/hash/hash_dup.c19
-rw-r--r--db2/hash/hash_func.c4
-rw-r--r--db2/hash/hash_page.c120
-rw-r--r--db2/hash/hash_rec.c36
-rw-r--r--db2/hash/hash_stat.c5
10 files changed, 265 insertions, 217 deletions
diff --git a/db2/hash/hash.c b/db2/hash/hash.c
index 5193ece561..5e0660b727 100644
--- a/db2/hash/hash.c
+++ b/db2/hash/hash.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -47,23 +47,19 @@
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash.c	10.36 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)hash.c	10.45 (Sleepycat) 5/11/98";
 #endif /* not lint */
 
 #ifndef NO_SYSTEM_INCLUDES
 #include <sys/types.h>
-#include <sys/stat.h>
 
 #include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #endif
 
-#include "shqueue.h"
 #include "db_int.h"
+#include "shqueue.h"
 #include "db_page.h"
 #include "db_am.h"
 #include "db_ext.h"
@@ -71,20 +67,20 @@ static const char sccsid[] = "@(#)hash.c	10.36 (Sleepycat) 1/8/98";
 #include "log.h"
 
 static int  __ham_c_close __P((DBC *));
-static int  __ham_c_del __P((DBC *, int));
-static int  __ham_c_get __P((DBC *, DBT *, DBT *, int));
-static int  __ham_c_put __P((DBC *, DBT *, DBT *, int));
+static int  __ham_c_del __P((DBC *, u_int32_t));
+static int  __ham_c_get __P((DBC *, DBT *, DBT *, u_int32_t));
+static int  __ham_c_put __P((DBC *, DBT *, DBT *, u_int32_t));
 static int  __ham_c_init __P((DB *, DB_TXN *, DBC **));
 static int  __ham_cursor __P((DB *, DB_TXN *, DBC **));
-static int  __ham_delete __P((DB *, DB_TXN *, DBT *, int));
-static int  __ham_dup_return __P((HTAB *, HASH_CURSOR *, DBT *, int));
-static int  __ham_get __P((DB *, DB_TXN *, DBT *, DBT *, int));
-static void __ham_init_htab __P((HTAB *, u_int));
+static int  __ham_delete __P((DB *, DB_TXN *, DBT *, u_int32_t));
+static int  __ham_dup_return __P((HTAB *, HASH_CURSOR *, DBT *, u_int32_t));
+static int  __ham_get __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
+static void __ham_init_htab __P((HTAB *, u_int32_t, u_int32_t));
 static int  __ham_lookup __P((HTAB *,
 		HASH_CURSOR *, const DBT *, u_int32_t, db_lockmode_t));
 static int  __ham_overwrite __P((HTAB *, HASH_CURSOR *, DBT *));
-static int  __ham_put __P((DB *, DB_TXN *, DBT *, DBT *, int));
-static int  __ham_sync __P((DB *, int));
+static int  __ham_put __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
+static int  __ham_sync __P((DB *, u_int32_t));
 
 /************************** INTERFACE ROUTINES ***************************/
 /* OPEN/CLOSE */
@@ -175,9 +171,9 @@ __ham_open(dbp, dbinfo)
 			goto out;
 		}
 
-		hashp->hdr->ffactor =
-		    dbinfo != NULL && dbinfo->h_ffactor ? dbinfo->h_ffactor : 0;
-		__ham_init_htab(hashp, dbinfo != NULL ? dbinfo->h_nelem : 0);
+		__ham_init_htab(hashp,
+		    dbinfo != NULL ? dbinfo->h_nelem : 0,
+		    dbinfo != NULL ? dbinfo->h_ffactor : 0);
 		if (F_ISSET(dbp, DB_AM_DUP))
 			F_SET(hashp->hdr, DB_HASH_DUP);
 		if ((ret = __ham_dirty_page(hashp, (PAGE *)hashp->hdr)) != 0)
@@ -230,7 +226,7 @@ out:	(void)__ham_close(dbp);
 }
 
 /*
- * PUBLIC: int  __ham_close __P((DB *));
+ * PUBLIC: int __ham_close __P((DB *));
  */
 int
 __ham_close(dbp)
@@ -264,13 +260,14 @@ __ham_close(dbp)
  * Returns 0 on No Error
  */
 static void
-__ham_init_htab(hashp, nelem)
+__ham_init_htab(hashp, nelem, ffactor)
 	HTAB *hashp;
-	u_int nelem;
+	u_int32_t nelem, ffactor;
 {
 	int32_t l2, nbuckets;
 
-	hashp->hdr->nelem = 0;
+	memset(hashp->hdr, 0, sizeof(HASHHDR));
+	hashp->hdr->ffactor = ffactor;
 	hashp->hdr->pagesize = hashp->dbp->pgsize;
 	ZERO_LSN(hashp->hdr->lsn);
 	hashp->hdr->magic = DB_HASHMAGIC;
@@ -287,8 +284,6 @@ __ham_init_htab(hashp, nelem)
 
 	nbuckets = 1 << l2;
 
-	hashp->hdr->spares[l2] = 0;
-	hashp->hdr->spares[l2 + 1] = 0;
 	hashp->hdr->ovfl_point = l2;
 	hashp->hdr->last_freed = PGNO_INVALID;
 
@@ -310,7 +305,7 @@ __ham_init_htab(hashp, nelem)
 static int
 __ham_sync(dbp, flags)
 	DB *dbp;
-	int flags;
+	u_int32_t flags;
 {
 	int ret;
 
@@ -342,10 +337,9 @@ __ham_get(dbp, txn, key, data, flags)
 	DB_TXN *txn;
 	DBT *key;
 	DBT *data;
-	int flags;
+	u_int32_t flags;
 {
 	DB *ldbp;
-	DBC *cp;
 	HTAB *hashp;
 	HASH_CURSOR *hcp;
 	int ret, t_ret;
@@ -362,7 +356,6 @@ __ham_get(dbp, txn, key, data, flags)
 	hashp = (HTAB *)ldbp->internal;
 	SET_LOCKER(ldbp, txn);
 	GET_META(ldbp, hashp);
-	cp = TAILQ_FIRST(&ldbp->curs_queue);
 
 	hashp->hash_accesses++;
 	hcp = (HASH_CURSOR *)TAILQ_FIRST(&ldbp->curs_queue)->internal;
@@ -386,14 +379,14 @@ __ham_put(dbp, txn, key, data, flags)
 	DB_TXN *txn;
 	DBT *key;
 	DBT *data;
-	int flags;
+	u_int32_t flags;
 {
 	DB *ldbp;
-	HTAB *hashp;
-	HASH_CURSOR *hcp;
 	DBT tmp_val, *myval;
-	int ret, t_ret;
+	HASH_CURSOR *hcp;
+	HTAB *hashp;
 	u_int32_t nbytes;
+	int ret, t_ret;
 
 	DEBUG_LWRITE(dbp, txn, "ham_put", key, data, flags);
 	if ((ret = __db_putchk(dbp, key, data,
@@ -531,7 +524,7 @@ __ham_delete(dbp, txn, key, flags)
 	DB *dbp;
 	DB_TXN *txn;
 	DBT *key;
-	int flags;
+	u_int32_t flags;
 {
 	DB *ldbp;
 	HTAB *hashp;
@@ -539,7 +532,8 @@ __ham_delete(dbp, txn, key, flags)
 	int ret, t_ret;
 
 	DEBUG_LWRITE(dbp, txn, "ham_delete", key, NULL, flags);
-	if ((ret = __db_delchk(dbp, flags, F_ISSET(dbp, DB_AM_RDONLY))) != 0)
+	if ((ret =
+	    __db_delchk(dbp, key, flags, F_ISSET(dbp, DB_AM_RDONLY))) != 0)
 		return (ret);
 
 	ldbp = dbp;
@@ -639,12 +633,12 @@ __ham_c_iclose(dbp, dbc)
 static int
 __ham_c_del(cursor, flags)
 	DBC *cursor;
-	int flags;
+	u_int32_t flags;
 {
 	DB *ldbp;
-	HTAB *hashp;
 	HASH_CURSOR *hcp;
 	HASH_CURSOR save_curs;
+	HTAB *hashp;
 	db_pgno_t ppgno, chg_pgno;
 	int ret, t_ret;
 
@@ -756,7 +750,7 @@ __ham_c_del(cursor, flags)
 normal:		ret = __ham_del_pair(hashp, hcp, 1);
 
 out:	if ((t_ret = __ham_item_done(hashp, hcp, ret == 0)) != 0 && ret == 0)
-		t_ret = ret;
+		ret = t_ret;
 	if (ret != 0)
 		*hcp = save_curs;
 	RELEASE_META(hashp->dbp, hashp);
@@ -770,7 +764,7 @@ __ham_c_get(cursor, key, data, flags)
 	DBC *cursor;
 	DBT *key;
 	DBT *data;
-	int flags;
+	u_int32_t flags;
 {
 	DB *ldbp;
 	HTAB *hashp;
@@ -805,7 +799,7 @@ __ham_c_get(cursor, key, data, flags)
 			ret = __ham_item_prev(hashp, hcp, DB_LOCK_READ);
 			break;
 		}
-		/* FALL THROUGH */
+		/* FALLTHROUGH */
 	case DB_LAST:
 		ret = __ham_item_last(hashp, hcp, DB_LOCK_READ);
 		break;
@@ -893,7 +887,7 @@ __ham_c_get(cursor, key, data, flags)
 		}
 	}
 out1:	if ((t_ret = __ham_item_done(hashp, hcp, 0)) != 0 && ret == 0)
-		t_ret = ret;
+		ret = t_ret;
 out:	if (ret)
 		*hcp = save_curs;
 	RELEASE_META(hashp->dbp, hashp);
@@ -907,17 +901,17 @@ __ham_c_put(cursor, key, data, flags)
 	DBC *cursor;
 	DBT *key;
 	DBT *data;
-	int flags;
+	u_int32_t flags;
 {
 	DB *ldbp;
-	HTAB *hashp;
 	HASH_CURSOR *hcp, save_curs;
-	int ret, t_ret;
+	HTAB *hashp;
 	u_int32_t nbytes;
+	int ret, t_ret;
 
 	DEBUG_LWRITE(cursor->dbp, cursor->txn, "ham_c_put",
 	    flags == DB_KEYFIRST || flags == DB_KEYLAST ? key : NULL,
-	    NULL, flags);
+	    data, flags);
 	ldbp = cursor->dbp;
 	if (F_ISSET(cursor->dbp, DB_AM_THREAD) &&
 	    (ret = __db_gethandle(cursor->dbp, __ham_hdup, &ldbp)) != 0)
@@ -1087,14 +1081,14 @@ __ham_dup_return(hashp, hcp, val, flags)
 	HTAB *hashp;
 	HASH_CURSOR *hcp;
 	DBT *val;
-	int flags;
+	u_int32_t flags;
 {
 	PAGE *pp;
 	DBT *myval, tmp_val;
 	db_indx_t ndx;
 	db_pgno_t pgno;
 	u_int8_t *hk, type;
-	int indx, ret;
+	int ret;
 	db_indx_t len;
 
 	/* Check for duplicate and return the first one. */
@@ -1145,7 +1139,6 @@ __ham_dup_return(hashp, hcp, val, flags)
 			memcpy(&pgno, HOFFDUP_PGNO(P_ENTRY(hcp->pagep, ndx)),
 			    sizeof(db_pgno_t));
 			if (flags == DB_LAST || flags == DB_PREV) {
-				indx = (int)hcp->dndx;
 				if ((ret = __db_dend(hashp->dbp,
 				    pgno, &hcp->dpagep)) != 0)
 					return (ret);
@@ -1451,14 +1444,15 @@ __ham_c_update(hcp, chg_pgno, len, add, is_dup)
  * __ham_hdup --
  *	This function gets called when we create a duplicate handle for a
  *	threaded DB.  It should create the private part of the DB structure.
+ *
  * PUBLIC: int  __ham_hdup __P((DB *, DB *));
  */
 int
 __ham_hdup(orig, new)
 	DB *orig, *new;
 {
-	HTAB *hashp;
 	DBC *curs;
+	HTAB *hashp;
 	int ret;
 
 	if ((hashp = (HTAB *)__db_malloc(sizeof(HTAB))) == NULL)
diff --git a/db2/hash/hash.src b/db2/hash/hash.src
index 8cbcee73f7..8a512830b8 100644
--- a/db2/hash/hash.src
+++ b/db2/hash/hash.src
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -43,11 +43,9 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)hash.src	10.2 (Sleepycat) 11/2/97
+ *	@(#)hash.src	10.3 (Sleepycat) 4/10/98
  */
 
-#include "config.h"
-
 /*
  * This is the source file used to create the logging functions for the
  * hash package.  Each access method (or set of routines wishing to register
diff --git a/db2/hash/hash_auto.c b/db2/hash/hash_auto.c
index 830ea46a4e..41b1ebed01 100644
--- a/db2/hash/hash_auto.c
+++ b/db2/hash/hash_auto.c
@@ -15,8 +15,6 @@
 #include "db_dispatch.h"
 #include "hash.h"
 #include "db_am.h"
-#include "common_ext.h"
-
 /*
  * PUBLIC: int __ham_insdel_log
  * PUBLIC:     __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
@@ -104,7 +102,7 @@ int __ham_insdel_log(logp, txnid, ret_lsnp, flags,
 		memcpy(bp, data->data, data->size);
 		bp += data->size;
 	}
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -120,22 +118,23 @@ int __ham_insdel_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_insdel_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_insdel_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_insdel_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_insdel_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -154,20 +153,20 @@ __ham_insdel_print(notused1, dbtp, lsnp, notused3, notused4)
 	    (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
 	printf("\tkey: ");
 	for (i = 0; i < argp->key.size; i++) {
-		c = ((char *)argp->key.data)[i];
-		if (isprint(c) || c == 0xa)
-			putchar(c);
+		ch = ((u_int8_t *)argp->key.data)[i];
+		if (isprint(ch) || ch == 0xa)
+			putchar(ch);
 		else
-			printf("%#x ", c);
+			printf("%#x ", ch);
 	}
 	printf("\n");
 	printf("\tdata: ");
 	for (i = 0; i < argp->data.size; i++) {
-		c = ((char *)argp->data.data)[i];
-		if (isprint(c) || c == 0xa)
-			putchar(c);
+		ch = ((u_int8_t *)argp->data.data)[i];
+		if (isprint(ch) || ch == 0xa)
+			putchar(ch);
 		else
-			printf("%#x ", c);
+			printf("%#x ", ch);
 	}
 	printf("\n");
 	printf("\n");
@@ -300,7 +299,7 @@ int __ham_newpage_log(logp, txnid, ret_lsnp, flags,
 	else
 		memset(bp, 0, sizeof(*nextlsn));
 	bp += sizeof(*nextlsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -316,22 +315,23 @@ int __ham_newpage_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_newpage_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_newpage_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_newpage_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_newpage_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -462,7 +462,7 @@ int __ham_splitmeta_log(logp, txnid, ret_lsnp, flags,
 	else
 		memset(bp, 0, sizeof(*metalsn));
 	bp += sizeof(*metalsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -478,22 +478,23 @@ int __ham_splitmeta_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_splitmeta_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_splitmeta_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_splitmeta_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_splitmeta_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -622,7 +623,7 @@ int __ham_splitdata_log(logp, txnid, ret_lsnp, flags,
 	else
 		memset(bp, 0, sizeof(*pagelsn));
 	bp += sizeof(*pagelsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -638,22 +639,23 @@ int __ham_splitdata_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_splitdata_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_splitdata_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_splitdata_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_splitdata_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -669,11 +671,11 @@ __ham_splitdata_print(notused1, dbtp, lsnp, notused3, notused4)
 	printf("\tpgno: %lu\n", (u_long)argp->pgno);
 	printf("\tpageimage: ");
 	for (i = 0; i < argp->pageimage.size; i++) {
-		c = ((char *)argp->pageimage.data)[i];
-		if (isprint(c) || c == 0xa)
-			putchar(c);
+		ch = ((u_int8_t *)argp->pageimage.data)[i];
+		if (isprint(ch) || ch == 0xa)
+			putchar(ch);
 		else
-			printf("%#x ", c);
+			printf("%#x ", ch);
 	}
 	printf("\n");
 	printf("\tpagelsn: [%lu][%lu]\n",
@@ -813,7 +815,7 @@ int __ham_replace_log(logp, txnid, ret_lsnp, flags,
 	}
 	memcpy(bp, &makedup, sizeof(makedup));
 	bp += sizeof(makedup);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -829,22 +831,23 @@ int __ham_replace_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_replace_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_replace_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_replace_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_replace_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -863,20 +866,20 @@ __ham_replace_print(notused1, dbtp, lsnp, notused3, notused4)
 	printf("\toff: %ld\n", (long)argp->off);
 	printf("\tolditem: ");
 	for (i = 0; i < argp->olditem.size; i++) {
-		c = ((char *)argp->olditem.data)[i];
-		if (isprint(c) || c == 0xa)
-			putchar(c);
+		ch = ((u_int8_t *)argp->olditem.data)[i];
+		if (isprint(ch) || ch == 0xa)
+			putchar(ch);
 		else
-			printf("%#x ", c);
+			printf("%#x ", ch);
 	}
 	printf("\n");
 	printf("\tnewitem: ");
 	for (i = 0; i < argp->newitem.size; i++) {
-		c = ((char *)argp->newitem.data)[i];
-		if (isprint(c) || c == 0xa)
-			putchar(c);
+		ch = ((u_int8_t *)argp->newitem.data)[i];
+		if (isprint(ch) || ch == 0xa)
+			putchar(ch);
 		else
-			printf("%#x ", c);
+			printf("%#x ", ch);
 	}
 	printf("\n");
 	printf("\tmakedup: %lu\n", (u_long)argp->makedup);
@@ -1014,7 +1017,7 @@ int __ham_newpgno_log(logp, txnid, ret_lsnp, flags,
 	else
 		memset(bp, 0, sizeof(*metalsn));
 	bp += sizeof(*metalsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -1030,22 +1033,23 @@ int __ham_newpgno_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_newpgno_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_newpgno_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_newpgno_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_newpgno_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -1182,7 +1186,7 @@ int __ham_ovfl_log(logp, txnid, ret_lsnp, flags,
 	else
 		memset(bp, 0, sizeof(*metalsn));
 	bp += sizeof(*metalsn);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -1198,22 +1202,23 @@ int __ham_ovfl_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_ovfl_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_ovfl_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_ovfl_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_ovfl_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -1364,7 +1369,7 @@ int __ham_copypage_log(logp, txnid, ret_lsnp, flags,
 		memcpy(bp, page->data, page->size);
 		bp += page->size;
 	}
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
 		fprintf(stderr, "Error in log record length");
 #endif
@@ -1380,22 +1385,23 @@ int __ham_copypage_log(logp, txnid, ret_lsnp, flags,
  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
  */
 int
-__ham_copypage_print(notused1, dbtp, lsnp, notused3, notused4)
+__ham_copypage_print(notused1, dbtp, lsnp, notused2, notused3)
 	DB_LOG *notused1;
 	DBT *dbtp;
 	DB_LSN *lsnp;
-	int notused3;
-	void *notused4;
+	int notused2;
+	void *notused3;
 {
 	__ham_copypage_args *argp;
 	u_int32_t i;
-	int c, ret;
+	u_int ch;
+	int ret;
 
 	i = 0;
-	c = 0;
+	ch = 0;
 	notused1 = NULL;
-	notused3 = 0;
-	notused4 = NULL;
+	notused2 = 0;
+	notused3 = NULL;
 
 	if ((ret = __ham_copypage_read(dbtp->data, &argp)) != 0)
 		return (ret);
@@ -1418,11 +1424,11 @@ __ham_copypage_print(notused1, dbtp, lsnp, notused3, notused4)
 	    (u_long)argp->nnextlsn.file, (u_long)argp->nnextlsn.offset);
 	printf("\tpage: ");
 	for (i = 0; i < argp->page.size; i++) {
-		c = ((char *)argp->page.data)[i];
-		if (isprint(c) || c == 0xa)
-			putchar(c);
+		ch = ((u_int8_t *)argp->page.data)[i];
+		if (isprint(ch) || ch == 0xa)
+			putchar(ch);
 		else
-			printf("%#x ", c);
+			printf("%#x ", ch);
 	}
 	printf("\n");
 	printf("\n");
diff --git a/db2/hash/hash_conv.c b/db2/hash/hash_conv.c
index 9cebe72390..c6d0ba4d4e 100644
--- a/db2/hash/hash_conv.c
+++ b/db2/hash/hash_conv.c
@@ -1,13 +1,13 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_conv.c	10.4 (Sleepycat) 9/15/97";
+static const char sccsid[] = "@(#)hash_conv.c	10.5 (Sleepycat) 4/10/98";
 #endif /* not lint */
 
 #ifndef NO_SYSTEM_INCLUDES
diff --git a/db2/hash/hash_debug.c b/db2/hash/hash_debug.c
index 979ddd7b87..232906ae34 100644
--- a/db2/hash/hash_debug.c
+++ b/db2/hash/hash_debug.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -43,7 +43,7 @@
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_debug.c	10.2 (Sleepycat) 6/21/97";
+static const char sccsid[] = "@(#)hash_debug.c	10.6 (Sleepycat) 5/7/98";
 #endif /* not lint */
 
 #ifdef DEBUG
@@ -60,9 +60,6 @@ static const char sccsid[] = "@(#)hash_debug.c	10.2 (Sleepycat) 6/21/97";
  */
 #ifndef NO_SYSTEM_INCLUDES
 #include <sys/types.h>
-
-#include <stdio.h>
-#include <string.h>
 #endif
 
 #include "db_int.h"
@@ -83,10 +80,9 @@ __ham_dump_bucket(hashp, bucket)
 {
 	PAGE *p;
 	db_pgno_t pgno;
-	int ret;
 
 	for (pgno = BUCKET_TO_PAGE(hashp, bucket); pgno != PGNO_INVALID;) {
-		if ((ret = memp_fget(hashp->dbp->mpf, &pgno, 0, &p)) != 0)
+		if (memp_fget(hashp->dbp->mpf, &pgno, 0, &p) != 0)
 			break;
 		(void)__db_prpage(p, 1);
 		pgno = p->next_pgno;
diff --git a/db2/hash/hash_dup.c b/db2/hash/hash_dup.c
index f8b0adb933..ba248ddb17 100644
--- a/db2/hash/hash_dup.c
+++ b/db2/hash/hash_dup.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -42,7 +42,7 @@
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_dup.c	10.10 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)hash_dup.c	10.14 (Sleepycat) 5/7/98";
 #endif /* not lint */
 
 /*
@@ -61,15 +61,11 @@ static const char sccsid[] = "@(#)hash_dup.c	10.10 (Sleepycat) 1/8/98";
 #ifndef NO_SYSTEM_INCLUDES
 #include <sys/types.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #endif
 
 #include "db_int.h"
 #include "db_page.h"
-#include "db_swap.h"
 #include "hash.h"
 
 static int __ham_check_move __P((HTAB *, HASH_CURSOR *, int32_t));
@@ -89,14 +85,14 @@ static int __ham_make_dup __P((const DBT *, DBT *d, void **, u_int32_t *));
  * Case 4: The element is large enough to push the duplicate set onto a
  *	   separate page.
  *
- * PUBLIC: int __ham_add_dup __P((HTAB *, HASH_CURSOR *, DBT *, int));
+ * PUBLIC: int __ham_add_dup __P((HTAB *, HASH_CURSOR *, DBT *, u_int32_t));
  */
 int
 __ham_add_dup(hashp, hcp, nval, flags)
 	HTAB *hashp;
 	HASH_CURSOR *hcp;
 	DBT *nval;
-	int flags;
+	u_int32_t flags;
 {
 	DBT pval, tmp_val;
 	u_int32_t del_len, new_size;
@@ -367,9 +363,9 @@ __ham_check_move(hashp, hcp, add_len)
 	DB_LSN new_lsn;
 	PAGE *next_pagep;
 	db_pgno_t next_pgno;
-	int rectype, ret;
-	u_int32_t new_datalen, old_len;
+	u_int32_t new_datalen, old_len, rectype;
 	u_int8_t *hk;
+	int ret;
 
 	/*
 	 * Check if we can do whatever we need to on this page.  If not,
@@ -419,7 +415,8 @@ __ham_check_move(hashp, hcp, add_len)
 		    (ret = __ham_put_page(hashp->dbp, next_pagep, 0)) != 0)
 			return (ret);
 
-		if ((ret = __ham_get_page(hashp->dbp, next_pgno, &next_pagep)) != 0)
+		if ((ret =
+		    __ham_get_page(hashp->dbp, next_pgno, &next_pagep)) != 0)
 			return (ret);
 
 		if (P_FREESPACE(next_pagep) >= new_datalen)
diff --git a/db2/hash/hash_func.c b/db2/hash/hash_func.c
index 1bf12c4948..9131098e5e 100644
--- a/db2/hash/hash_func.c
+++ b/db2/hash/hash_func.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -47,7 +47,7 @@
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_func.c	10.7 (Sleepycat) 9/16/97";
+static const char sccsid[] = "@(#)hash_func.c	10.8 (Sleepycat) 4/10/98";
 #endif /* not lint */
 
 #ifndef NO_SYSTEM_INCLUDES
diff --git a/db2/hash/hash_page.c b/db2/hash/hash_page.c
index 09a4a0c374..ce692f2e41 100644
--- a/db2/hash/hash_page.c
+++ b/db2/hash/hash_page.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -47,7 +47,7 @@
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_page.c	10.31 (Sleepycat) 1/8/98";
+static const char sccsid[] = "@(#)hash_page.c	10.40 (Sleepycat) 6/2/98";
 #endif /* not lint */
 
 /*
@@ -70,15 +70,11 @@ static const char sccsid[] = "@(#)hash_page.c	10.31 (Sleepycat) 1/8/98";
 #include <sys/types.h>
 
 #include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #endif
 
 #include "db_int.h"
 #include "db_page.h"
-#include "db_swap.h"
 #include "hash.h"
 
 static int __ham_lock_bucket __P((DB *, HASH_CURSOR *, db_lockmode_t));
@@ -266,6 +262,7 @@ __ham_item_last(hashp, cursorp, mode)
 	F_SET(cursorp, H_OK);
 	return (__ham_item_prev(hashp, cursorp, mode));
 }
+
 /*
  * PUBLIC: int __ham_item_first __P((HTAB *, HASH_CURSOR *, db_lockmode_t));
  */
@@ -285,8 +282,10 @@ __ham_item_first(hashp, cursorp, mode)
 }
 
 /*
- * Returns a pointer to key/data pair on a page.  In the case of bigkeys,
- * just returns the page number and index of the bigkey pointer pair.
+ * __ham_item_prev --
+ *	Returns a pointer to key/data pair on a page.  In the case of
+ *	bigkeys, just returns the page number and index of the bigkey
+ *	pointer pair.
  *
  * PUBLIC: int __ham_item_prev __P((HTAB *, HASH_CURSOR *, db_lockmode_t));
  */
@@ -487,12 +486,61 @@ __ham_putitem(p, dbt, type)
 	NUM_ENT(p) += 1;
 }
 
+/*
+ * PUBLIC: void __ham_reputpair
+ * PUBLIC:    __P((PAGE *p, u_int32_t, u_int32_t, const DBT *, const DBT *));
+ *
+ * This is a special case to restore a key/data pair to its original
+ * location during recovery.  We are guaranteed that the pair fits
+ * on the page and is not the last pair on the page (because if it's
+ * the last pair, the normal insert works).
+ */
+void
+__ham_reputpair(p, psize, ndx, key, data)
+	PAGE *p;
+	u_int32_t psize, ndx;
+	const DBT *key, *data;
+{
+	db_indx_t i, movebytes, newbytes;
+	u_int8_t *from;
+
+	/* First shuffle the existing items up on the page.  */
+	movebytes =
+	    (ndx == 0 ? psize : p->inp[H_DATAINDEX(ndx - 1)]) - HOFFSET(p);
+	newbytes = key->size + data->size;
+	from = (u_int8_t *)p + HOFFSET(p);
+	memmove(from - newbytes, from, movebytes);
+
+	/*
+	 * Adjust the indices and move them up 2 spaces. Note that we
+	 * have to check the exit condition inside the loop just in case
+	 * we are dealing with index 0 (db_indx_t's are unsigned).
+	 */
+	for (i = NUM_ENT(p) - 1; ; i-- ) {
+		p->inp[i + 2] = p->inp[i] - newbytes;
+		if (i == H_KEYINDEX(ndx))
+			break;
+	}
+
+	/* Put the key and data on the page. */
+	p->inp[H_KEYINDEX(ndx)] =
+	    (ndx == 0 ? psize : p->inp[H_DATAINDEX(ndx - 1)]) - key->size;
+	p->inp[H_DATAINDEX(ndx)] = p->inp[H_KEYINDEX(ndx)] - data->size;
+	memcpy(P_ENTRY(p, H_KEYINDEX(ndx)), key->data, key->size);
+	memcpy(P_ENTRY(p, H_DATAINDEX(ndx)), data->data, data->size);
+
+	/* Adjust page info. */
+	HOFFSET(p) -= newbytes;
+	NUM_ENT(p) += 2;
+}
+
 
 /*
  * PUBLIC: int __ham_del_pair __P((HTAB *, HASH_CURSOR *, int));
- * XXX TODO: if the item is an offdup, delete the other pages and
- * then remove the pair. If the offpage page is 0, then you can
- * just remove the pair.
+ *
+ * XXX
+ * TODO: if the item is an offdup, delete the other pages and then remove
+ * the pair. If the offpage page is 0, then you can just remove the pair.
  */
 int
 __ham_del_pair(hashp, cursorp, reclaim_page)
@@ -648,8 +696,9 @@ __ham_del_pair(hashp, cursorp, reclaim_page)
 		/*
 		 * Cursor is advanced to the beginning of the next page.
 		 */
-		cursorp->bndx = NDX_INVALID;
+		cursorp->bndx = 0;
 		cursorp->pgno = PGNO(p);
+		F_SET(cursorp, H_DELETED);
 		chg_pgno = PGNO(p);
 		if ((ret = __ham_dirty_page(hashp, p)) != 0 ||
 		    (ret = __ham_del_page(hashp->dbp, n_pagep)) != 0)
@@ -748,8 +797,8 @@ __ham_replpair(hashp, hcp, dbt, make_dup)
 {
 	DBT old_dbt, tdata, tmp;
 	DB_LSN	new_lsn;
+	int32_t change;			/* XXX: Possible overflow. */
 	u_int32_t len;
-	int32_t change;
 	int is_big, ret, type;
 	u_int8_t *beg, *dest, *end, *hk, *src;
 
@@ -789,7 +838,7 @@ __ham_replpair(hashp, hcp, dbt, make_dup)
 		change += dbt->doff + dbt->dlen - len;
 
 
-	if (change > (int)P_FREESPACE(hcp->pagep) || is_big) {
+	if (change > (int32_t)P_FREESPACE(hcp->pagep) || is_big) {
 		/*
 		 * Case 3 -- two subcases.
 		 * A. This is not really a partial operation, but an overwrite.
@@ -954,7 +1003,7 @@ __ham_split_page(hashp, obucket, nbucket)
 	HTAB *hashp;
 	u_int32_t obucket, nbucket;
 {
-	DBT key, val, page_dbt;
+	DBT key, page_dbt;
 	DB_ENV *dbenv;
 	DB_LSN new_lsn;
 	PAGE **pp, *old_pagep, *temp_pagep, *new_pagep;
@@ -995,7 +1044,7 @@ __ham_split_page(hashp, obucket, nbucket)
 
 	big_len = 0;
 	big_buf = NULL;
-	val.flags = key.flags = 0;
+	key.flags = 0;
 	while (temp_pagep != NULL) {
 		for (n = 0; n < (db_indx_t)H_NUMPAIRS(temp_pagep); n++) {
 			if ((ret =
@@ -1103,8 +1152,8 @@ __ham_split_page(hashp, obucket, nbucket)
 	    ret == 0)
 		ret = tret;
 
-err:	if (0) {
-		if (old_pagep != NULL)
+	if (0) {
+err:		if (old_pagep != NULL)
 			(void)__ham_put_page(hashp->dbp, old_pagep, 1);
 		if (new_pagep != NULL)
 			(void)__ham_put_page(hashp->dbp, new_pagep, 1);
@@ -1121,8 +1170,8 @@ err:	if (0) {
  * to which we just added something.  This allows us to link overflow
  * pages and return the new page having correctly put the last page.
  *
- * PUBLIC: int __ham_add_el __P((HTAB *, HASH_CURSOR *, const DBT *, const DBT *,
- * PUBLIC:     int));
+ * PUBLIC: int __ham_add_el
+ * PUBLIC:    __P((HTAB *, HASH_CURSOR *, const DBT *, const DBT *, int));
  */
 int
 __ham_add_el(hashp, hcp, key, val, type)
@@ -1136,8 +1185,8 @@ __ham_add_el(hashp, hcp, key, val, type)
 	DB_LSN new_lsn;
 	HOFFPAGE doff, koff;
 	db_pgno_t next_pgno;
-	u_int32_t data_size, key_size, pairsize;
-	int do_expand, is_keybig, is_databig, rectype, ret;
+	u_int32_t data_size, key_size, pairsize, rectype;
+	int do_expand, is_keybig, is_databig, ret;
 	int key_type, data_type;
 
 	do_expand = 0;
@@ -1268,13 +1317,14 @@ __ham_add_el(hashp, hcp, key, val, type)
  * another.  Works for all types of hash entries (H_OFFPAGE, H_KEYDATA,
  * H_DUPLICATE, H_OFFDUP).  Since we log splits at a high level, we
  * do not need to do any logging here.
- * PUBLIC: void __ham_copy_item __P((HTAB *, PAGE *, int, PAGE *));
+ *
+ * PUBLIC: void __ham_copy_item __P((HTAB *, PAGE *, u_int32_t, PAGE *));
  */
 void
 __ham_copy_item(hashp, src_page, src_ndx, dest_page)
 	HTAB *hashp;
 	PAGE *src_page;
-	int src_ndx;
+	u_int32_t src_ndx;
 	PAGE *dest_page;
 {
 	u_int32_t len;
@@ -1409,7 +1459,7 @@ __ham_del_page(dbp, pagep)
 		LSN(pagep) = new_lsn;
 	}
 
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	{
 		db_pgno_t __pgno;
 		DB_LSN __lsn;
@@ -1563,13 +1613,13 @@ __ham_overflow_page(dbp, type, pp)
 #ifdef DEBUG
 /*
  * PUBLIC: #ifdef DEBUG
- * PUBLIC: int __bucket_to_page __P((HTAB *, int));
+ * PUBLIC: db_pgno_t __bucket_to_page __P((HTAB *, db_pgno_t));
  * PUBLIC: #endif
  */
-int
+db_pgno_t
 __bucket_to_page(hashp, n)
 	HTAB *hashp;
-	int n;
+	db_pgno_t n;
 {
 	int ret_val;
 
@@ -1580,7 +1630,6 @@ __bucket_to_page(hashp, n)
 }
 #endif
 
-
 /*
  * Create a bunch of overflow pages at the current split point.
  * PUBLIC: void __ham_init_ovflpages __P((HTAB *));
@@ -1660,8 +1709,9 @@ __ham_get_cpage(hashp, hcp, mode)
  * Get a new page at the cursor, putting the last page if necessary.
  * If the flag is set to H_ISDUP, then we are talking about the
  * duplicate page, not the main page.
- * PUBLIC: int __ham_next_cpage __P((HTAB *, HASH_CURSOR *, db_pgno_t,
- * PUBLIC:     int, int));
+ *
+ * PUBLIC: int __ham_next_cpage
+ * PUBLIC:    __P((HTAB *, HASH_CURSOR *, db_pgno_t, int, u_int32_t));
  */
 int
 __ham_next_cpage(hashp, hcp, pgno, dirty, flags)
@@ -1669,22 +1719,22 @@ __ham_next_cpage(hashp, hcp, pgno, dirty, flags)
 	HASH_CURSOR *hcp;
 	db_pgno_t pgno;
 	int dirty;
-	int flags;
+	u_int32_t flags;
 {
 	PAGE *p;
 	int ret;
 
-	if (flags & H_ISDUP && hcp->dpagep != NULL &&
+	if (LF_ISSET(H_ISDUP) && hcp->dpagep != NULL &&
 	    (ret = __ham_put_page(hashp->dbp, hcp->dpagep, dirty)) != 0)
 		return (ret);
-	else if (!(flags & H_ISDUP) && hcp->pagep != NULL &&
+	else if (!LF_ISSET(H_ISDUP) && hcp->pagep != NULL &&
 	    (ret = __ham_put_page(hashp->dbp, hcp->pagep, dirty)) != 0)
 		return (ret);
 
 	if ((ret = __ham_get_page(hashp->dbp, pgno, &p)) != 0)
 		return (ret);
 
-	if (flags & H_ISDUP) {
+	if (LF_ISSET(H_ISDUP)) {
 		hcp->dpagep = p;
 		hcp->dpgno = pgno;
 		hcp->dndx = 0;
diff --git a/db2/hash/hash_rec.c b/db2/hash/hash_rec.c
index 09508251a2..efaf61c638 100644
--- a/db2/hash/hash_rec.c
+++ b/db2/hash/hash_rec.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -47,14 +47,13 @@
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_rec.c	10.15 (Sleepycat) 12/4/97";
+static const char sccsid[] = "@(#)hash_rec.c	10.19 (Sleepycat) 5/23/98";
 #endif /* not lint */
 
 #ifndef NO_SYSTEM_INCLUDES
 #include <sys/types.h>
 
 #include <errno.h>
-#include <stdlib.h>
 #include <string.h>
 #endif
 
@@ -64,7 +63,6 @@ static const char sccsid[] = "@(#)hash_rec.c	10.15 (Sleepycat) 12/4/97";
 #include "hash.h"
 #include "btree.h"
 #include "log.h"
-#include "db_dispatch.h"
 #include "common_ext.h"
 
 /*
@@ -131,13 +129,23 @@ __ham_insdel_recover(logp, dbtp, lsnp, redo, info)
 
 	if ((op == DELPAIR && cmp_n == 0 && !redo) ||
 	    (op == PUTPAIR && cmp_p == 0 && redo)) {
-		/* Need to redo a PUT or undo a delete. */
-		__ham_putitem(pagep, &argp->key,
-		    !redo || PAIR_ISKEYBIG(argp->opcode) ?
-		    H_OFFPAGE : H_KEYDATA);
-		__ham_putitem(pagep, &argp->data,
-		    !redo || PAIR_ISDATABIG(argp->opcode) ?
-		    H_OFFPAGE : H_KEYDATA);
+		/*
+		 * Need to redo a PUT or undo a delete.  If we are undoing a
+		 * delete, we've got to restore the item back to its original
+		 * position.  That's a royal pain in the butt (because we do
+		 * not store item lengths on the page), but there's no choice.
+		 */
+		if (op != DELPAIR ||
+		    argp->ndx == (u_int32_t)H_NUMPAIRS(pagep)) {
+			__ham_putitem(pagep, &argp->key,
+			    !redo || PAIR_ISKEYBIG(argp->opcode) ?
+			    H_OFFPAGE : H_KEYDATA);
+			__ham_putitem(pagep, &argp->data,
+			    !redo || PAIR_ISDATABIG(argp->opcode) ?
+			    H_OFFPAGE : H_KEYDATA);
+		} else
+			(void) __ham_reputpair(pagep, hashp->hdr->pagesize,
+			    argp->ndx, &argp->key, &argp->data);
 
 		LSN(pagep) = redo ? *lsnp : argp->pagelsn;
 		if ((ret = __ham_put_page(file_dbp, pagep, 1)) != 0)
@@ -453,7 +461,7 @@ __ham_newpgno_recover(logp, dbtp, lsnp, redo, info)
 	DBT *dbtp;
 	DB_LSN *lsnp;
 	int redo;
-	 void *info;
+	void *info;
 {
 	__ham_newpgno_args *argp;
 	DB *mdbp, *file_dbp;
@@ -574,7 +582,7 @@ __ham_splitmeta_recover(logp, dbtp, lsnp, redo, info)
 	DBT *dbtp;
 	DB_LSN *lsnp;
 	int redo;
-	 void *info;
+	void *info;
 {
 	__ham_splitmeta_args *argp;
 	DB *mdbp, *file_dbp;
@@ -649,7 +657,7 @@ __ham_splitdata_recover(logp, dbtp, lsnp, redo, info)
 	DBT *dbtp;
 	DB_LSN *lsnp;
 	int redo;
-	 void *info;
+	void *info;
 {
 	__ham_splitdata_args *argp;
 	DB *mdbp, *file_dbp;
diff --git a/db2/hash/hash_stat.c b/db2/hash/hash_stat.c
index 99c6078d86..b57ca0950d 100644
--- a/db2/hash/hash_stat.c
+++ b/db2/hash/hash_stat.c
@@ -1,14 +1,14 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 
 #include "config.h"
 
 #ifndef lint
-static const char sccsid[] = "@(#)hash_stat.c	10.6 (Sleepycat) 7/2/97";
+static const char sccsid[] = "@(#)hash_stat.c	10.8 (Sleepycat) 4/26/98";
 #endif /* not lint */
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -20,7 +20,6 @@ static const char sccsid[] = "@(#)hash_stat.c	10.6 (Sleepycat) 7/2/97";
 #include "db_int.h"
 #include "db_page.h"
 #include "hash.h"
-#include "common_ext.h"
 
 /*
  * __ham_stat --