Re: db->seq never gets to end

Alistair Crooks <[email protected]>
Newsgroups gmane.os.netbsd.help
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.