Skip to content

Commit

Permalink
fix walker moving forward after delete
Browse files Browse the repository at this point in the history
Fix for issue #5 that represents situation when walker doesn't move
forward after deleting unrelated record.
  • Loading branch information
Nikolay Orliuk committed Sep 2, 2014
1 parent fb6089f commit 88c41c6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions include/leveldb/memory_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ namespace leveldb
// re-sync with container if needed
bool Sync()
{
if (rev != rows->rev)
{
rev = rows->rev;
// need to re-align on access if applicable
if (Valid())
{ SeekImpl(savepoint); }
return true;
}
return false;
if (rev == rows->rev) return false;
rev = rows->rev;
if (!Valid()) return true; // invalid position already re-synced
// need to re-align
SeekImpl(savepoint);
// this might look a bit complicated but in fact we return true
// when if we synced to some other record (even if it is wrong)
// that is not the last one we've been pointing too
// (ex. because of delete).
return !Valid() || savepoint != impl->first;
}

void Synced()
Expand Down

0 comments on commit 88c41c6

Please sign in to comment.