[redland] Bug w/ remove statement under BDB storage

Chad House chadh at pobox.com
Mon May 13 13:41:49 BST 2002


I poked around the source a bit, and think I've found the problem.

'librdf_hash_bdb_delete_key_value' in rdf_hash_bdb.c calls the
database cursor's c_get function with a flag of DB_SET:

   /* V2/V3 prototype:
    * int DBcursor->c_get(DBC *cursor, DBT *key, DBT *data, u_int32_t flags);
    */
   ret=dbc->c_get(dbc, &bdb_key, &bdb_value, DB_SET);
   if(ret) {
     dbc->c_close(dbc);
     return 1;
   }

but according to the BDB documentation[1] for the DB_SET flag, "In the
presence of duplicate key values, DBcursor->c_get will return the
first data item for the given key" -- which would explain the
behaviour I was seeing.

I think the flag should be DB_GET_BOTH:

/---
| DB_GET_BOTH
|
|    The DB_GET_BOTH flag is identical to the DB_SET flag, except that
|    both the key and the data arguments must be matched by the key and
|    data item in the database.
\---

I changed the flag in my local copy and now my testcase does the right
thing.

Chad


Footnotes: 
[1]  http://sleepycat.com/docs/api_c/dbc_get.html






More information about the redland-dev mailing list