Has dbm ever worked?

Chris Torek chris at umcp-cs.UUCP
Thu Oct 9 00:26:33 AEST 1986


In article <240 at ima.UUCP> johnl at ima.UUCP (John R. Levine) writes:
>... It appears to me that nextkey() has never worked for databases
>larger than one block.  In the nextkey routine, it goes through
>some magic to get a key, and then (for reasonable reasons) checks
>to make sure that the key is in the data base and not the very
>first key.  Unfortunately, when it looks up the very first key,
>that uses the same buffer where the key it was looking at lived,
>and smashes it.

The 4.2 nextkey() does not work this way.  It uses the key to
calculate the proper block, then finds the next object in that
block (the one that follows the item given to nextkey).  If it
reaches the end of the block, it moves to the next block.

The 4.3 nextkey() does something entirely different and incompatible,
and therefore broken, though certainly more efficient.  In
particular, the 4.2 nextkey() would give you The Next Key after
its argument.  The 4.3 nextkey() gives you the next key after the
previous call to nextkey().  If all your calls to nextkey() are
sequential, this is equivalent.  Of all the programs that use dbm
or ndbm, I know of none that do not make sequential calls, for
whatever that is worth.

I submit that your vendor, like Berkeley, sought to `improve' Ken's
code, and, like Berkeley, broke it.  Unlike Berkeley, they failed
to test it.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.unix.wizards mailing list