On Mon, 2015-05-18 at 23:03 +0200, Hallvard Breien Furuseth wrote:
On 12/05/15 19:36, Howard Chu wrote:
> Dmytro Milinevskyy wrote:
> > Basically I need to have an opportunity to call mdb_get while in
> > write
> > transaction.
> > The sequence is smth like:
> > - txn = mdb_txn_begin(flags=0)
> > for i in 0..x:
> > - v = mdb_get(txn, i)
> > - mdb_put(txn, x+i, v)
> > - mdb_put(txn, i, v+1)
> > - mdb_txn_commit(txn)
> > Will it be always valid data?
...No. I expect he means v = the MDB_val returned by mdb_get().
mdb_put() can modify the data it points at.
See the MDB_val documentation in ldmb.h:
* Values returned from the database are valid only until a
* update operation, or the end of the transaction. Do not modify or
* free them, they commonly point into the database itself.
What exactly does a subsequent update operation mean? Overwriting the
value of the same key, or any mdb_put or mdb_cursor_put operation at
all, regardless of which key they touch?