couchbase / forestdb

A Fast Key-Value Storage Engine Based on Hierarchical B+-Tree Trie
Apache License 2.0
1.29k stars 172 forks source link

MB-13095 fdb_get_byoffset fails if only offset specified #7

Closed vhbit closed 9 years ago

vhbit commented 9 years ago

Example:

let mut doc: *mut ffi::fdb_doc = ptr::null_mut();
ffi::fdb_doc_create(&mut doc,
                    ptr::null_mut(), 0,
                    ptr::null_mut(), 0,
                    ptr::null_mut(), 0);
(*doc).offset = doc1.offset(); // actual offset
// if this line is missing - result is key not found error
(*doc).seqnum = 0xffffffffffffffff;
// (*doc).seqnum = doc1.seq_num(); // this works too

let res = ffi::fdb_get_byoffset(store.get_raw(), doc);
assert_eq!(res, 0);

Happened because fdb_doc_create sets seqnum to 0 and later on equal_doc returns false as considers 0 to be a correct value to check against found document.

chiyoung commented 9 years ago

Thanks for reporting this bug and uploading the fix.

We use Gerrit to review a fix and push it into the github master branch. I made a fix and pushed it into our Gerrit branch:

http://review.couchbase.org/#/c/45327/