Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site uwvax.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!hogpc!houti!ariel!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!uwvax!dave
From: dave@uwvax.UUCP
Newsgroups: net.unix-wizards
Subject: mdbm deletion bug (and fix)
Message-ID: <383@uwvax.ARPA>
Date: Mon, 13-Aug-84 13:13:43 EDT
Article-I.D.: uwvax.383
Posted: Mon Aug 13 13:13:43 1984
Date-Received: Wed, 15-Aug-84 01:32:11 EDT
Organization: U of Wisconsin CS Dept
Lines: 32

I tried out the mdbm software from Maryland and found a problem when
deleting records.  The problem is that mdbm keeps track of the number
of keys in its buffer table (I think) and the deletion stuff doesn't
take this into account when deleting records.  The fix is in delete.c
and a diff follows.  Basically, delete must re-retrieve the key to get
its updated index before deleting it.  With this fix, the mdbm software
seems to work very well.

*** delete.c.orig	Mon Aug 13 03:30:17 1984
--- delete.c	Mon Aug 13 03:28:13 1984
***************
*** 34,39
  	mdbm_delitem (d, de - db -> db_e);
  
  	/* delete the key */
  	MDBM_DREAD (d, keyblock);
  	de = &db -> db_e[keyindex];
  	de -> de_outx = 0;		/* not in use as a key anymore */

--- 34,40 -----
  	mdbm_delitem (d, de - db -> db_e);
  
  	/* delete the key */
+ 	de = mdbm_search (d, key.dptr, key.dsize, &keyblock, &keyindex, 1);
  	MDBM_DREAD (d, keyblock);
  	de = &db -> db_e[keyindex];
  	de -> de_outx = 0;		/* not in use as a key anymore */

-- 
Dave Cohrs @ wisconsin
...!{allegra,heurikon,ihnp4,seismo,ucbvax,uwm-evax}!uwvax!dave
dave@wisc-rsch.arpa