Subject: Re: db->seq never gets to end
To: Jeremy C. Reed <reed@reedmedia.net>
From: Alistair Crooks <agc@pkgsrc.org>
List: netbsd-help
Date: 08/14/2007 16:06:41
On Thu, Aug 09, 2007 at 10:57:39PM -0500, Jeremy C. Reed wrote:
> Hopefully this list is okay ...
>
> I am using:
>
> for (r = db->seq(db, &dbk, &dbd, R_FIRST); !r;
> r = db->seq(db, &dbk, &dbd, R_NEXT)) {
>
> But sometimes it never ends.
>
> I added a counter. And it would get to hundreds of thousands and data
> would repeat. I only have less than 1500 keys. I'd also get dbd.size that
> would be hundreds of thousands of bytes (but should only be 20 bytes).
>
> Is there any way to ask the hash(3) how many elements it has?
Maybe it's just me, but I didn't even realise that you could
do a sequential scan of a hashed database. dbopen(3) says:
R_LAST and R_PREV are available only for the
DB_BTREE and DB_RECNO access methods because they
each imply that the keys have an inherent order
which does not change.
Given that statement, I don't see how R_FIRST and R_NEXT are
any different, but I'm getting old and confused.
Was this software meant to use a different version of Berkeley
db?
Regards,
Alistair