Skip to content

Commit

Permalink
FirstDup support (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Mar 8, 2023
1 parent eda876f commit 12532c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mdbx/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (c *Cursor) Get(setkey, setval []byte, op uint) (key, val []byte, err error
if op == Set {
key = setkey
} else {
if op != LastDup {
if op != LastDup && op != FirstDup {
key = castToBytes(c.txn.key)
}
}
Expand Down
17 changes: 15 additions & 2 deletions mdbx/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,29 @@ func TestLastDup(t *testing.T) {
return err
}
i++

_, v, err := c.Get(nil, nil, LastDup)
if err != nil {
return err
}
if i == 1 && string(v) != "value1.3" {
t.Fail()
panic(1)
}
if i == 2 && string(v) != "value3.3" {
t.Fail()
panic(1)
}

_, v, err = c.Get(nil, nil, FirstDup)
if err != nil {
return err
}
if i == 1 && string(v) != "value1.1" {
panic(1)
}
if i == 2 && string(v) != "value3.1" {
panic(1)
}

}

return nil
Expand Down

0 comments on commit 12532c9

Please sign in to comment.