Skip to content

PutCurrent method

Choose a tag to compare

@AskAlexSharov AskAlexSharov released this 16 Mar 05:52
· 2 commits to release/0.39 since this release
2de3265
mdbx: add Cursor.PutCurrent for DupSort in-place dup replacement (#208)

* mdbx: add Cursor.PutCurrent for DupSort in-place dup replacement

For DupSort tables, after positioning with Get(GetBothRange), calling
PutCurrent(key, newVal) replaces the current duplicate entry in-place
using MDBX_CURRENT flag — saving one CGo call per update vs the
previous Del(Current)+Put() pattern.

Add TestCursor_PutCurrent_DupSort verifying the Erigon domain flush
pattern: insert (key, stepPrefix+payload) pairs, seek to exact step,
replace payload in-place, verify count and values are correct.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* mdbx: fix appendAssign lint in TestCursor_PutCurrent_DupSort

Use explicit copies for val1/val2 to avoid appending to step1/step2
backing arrays (gocritic appendAssign).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* mdbx: simplify TestCursor_PutCurrent_DupSort — merge 4 txns into 2

Combine DBI open + insert into one transaction (matching the pattern
used in other DupSort tests). Combine PutCurrent + verification into
one transaction (read-your-own-writes within an Update works fine).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* go.mod: bump go directive to 1.24 for b.Loop() support

BenchmarkCursor_Put_Sequence uses testing.Loop which requires go1.24.
The toolchain was already go1.24.1; align the go directive to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>