Timur Kristóf wrote:
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?Yes....No. I expect he means v = the MDB_val returned by mdb_get(). mdb_put() can modify the data it points at.
Since he's using "v+1" in his example I assumed he's making a local copy of the returned values. Anyway, the plain answer to the question in the Subject is Yes.
See the MDB_val documentation in ldmb.h: * Values returned from the database are valid only until a subsequent * 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,
If we meant "same key" we would have said so.
or any mdb_put or mdb_cursor_put operation at all, regardless of which key they touch?
-- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/