Skip to content

Commit e1ec625

Browse files
committed
Fix database bindings
1 parent 6546311 commit e1ec625

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

lmdb/lmdb_db.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,8 @@ DB::Status LmdbDB::Scan(const std::string &table, const std::string &key, int le
235235
if (ret) {
236236
throw utils::Exception(std::string("Scan mdb_cursor_open: ") + mdb_strerror(ret));
237237
}
238-
ret = mdb_cursor_get(cursor, &key_slice, &val_slice, MDB_SET);
238+
ret = mdb_cursor_get(cursor, &key_slice, &val_slice, MDB_SET_RANGE);
239239
if (ret == MDB_NOTFOUND) {
240-
s = kNotFound;
241240
goto cleanup;
242241
} else if (ret) {
243242
throw utils::Exception(std::string("Scan mdb_cursor_get: ") + mdb_strerror(ret));

sqlite/sqlite_db.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ DB::Status SqliteDB::Scan(const std::string &table, const std::string &key, int
282282
}
283283
}
284284

285-
if (result.size() == 0) {
286-
s = kNotFound;
287-
}
288-
289285
cleanup:
290286
sqlite3_reset(stmt);
291287
sqlite3_clear_bindings(stmt);

wiredtiger/wiredtiger_db.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,17 @@ DB::Status WTDB::ScanSingleEntry(const std::string &table, const std::string &ke
234234
int ret = 0, exact;
235235

236236
cursor_->set_key(cursor_, &k);
237-
error_check(cursor_->search_near(cursor_, &exact));
237+
ret = cursor_->search_near(cursor_, &exact);
238+
if (ret == WT_NOTFOUND) {
239+
return kOK;
240+
}
241+
error_check(ret);
238242
if (exact < 0) {
239243
ret = cursor_->next(cursor_);
244+
if (ret == WT_NOTFOUND) {
245+
return kOK;
246+
}
247+
error_check(ret);
240248
}
241249
for(int i=0; !ret && i<len; ++i){
242250
error_check(cursor_->get_value(cursor_, &v));
@@ -246,6 +254,10 @@ DB::Status WTDB::ScanSingleEntry(const std::string &table, const std::string &ke
246254
} else {
247255
DeserializeRow(&result.back(), (const char*)v.data, v.size);
248256
}
257+
ret = cursor_->next(cursor_);
258+
if (ret != 0 && ret != WT_NOTFOUND) {
259+
error_check(ret);
260+
}
249261
}
250262
return kOK;
251263
}

wiredtiger/wiredtiger_db.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class WTDB : public DB {
8585

8686
};
8787

88-
DB *NewRocksdbDB();
88+
DB *NewWTDB();
8989

9090
} // namespace ycsbc
9191

0 commit comments

Comments
 (0)