You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, heed is too restrictive on the write transactions and do not permit certain basic operations like writing the content of one database into another as the example shows below.
According to the documentation, write transactions were designed to support this kind of operations on the same database too.
Which means that the following example could even work with the same database.
It would, therefore, be possible for heed replace the places where we use &mut RwTxn with, a less restrictive, &RwTxn.
letmut wtxn = env.write_txn()?;for result in database1.iter(&wtxn)? {let(k, v) = result?;
database2.put(&mut wtxn, k, v)?;// can't compile &mut and & of the same RwTxn used at the same time}
The text was updated successfully, but these errors were encountered:
yes of course. ACID transactions would be pretty useless if they didn't support operations on multiple DBs in the same txn. That is the prime requirement for the C "Consistency" in ACID.
yes. Note that the mtest*.c test programs already demonstrate this.
Unfortunately, the changes made in #190 are invalid as the following rule is no more ensured at compile-time:
Values returned from the database are valid only until a subsequent update operation, or the end of the transaction.
To continue, possible solutions to enable the original limitation described by this issue. We could expose an unsafe new method on the RwTxn struct to create two SplitRwTxn. These split transactions implement DerefMut to behave like normal RwTxn. By declaring it as unsafe we can explain the security concerns but the possibilities it unlocks.
/// Returns `N` views of a mutable transaction. Don't use it like you would use an `RwTxn`.unsafefnRwTxn::split<constN:usize>(&mutself) -> [SplitRwTxn;N];letmut wtxn = env.write_txn()?;let[mut wtxn1,mut wtxn2] = unsafe{ wtxn.split()};for result in database1.iter(&wtxn1)? {let(k, v) = result?;
database2.put(&mut wtxn2, k, v)?;}// by dropping wtxn1 and wtxn2 you can commit the original wtxn
wtxn.commit()?;
Currently, heed is too restrictive on the write transactions and do not permit certain basic operations like writing the content of one database into another as the example shows below.
According to the documentation, write transactions were designed to support this kind of operations on the same database too.
Which means that the following example could even work with the same database.
It would, therefore, be possible for heed replace the places where we use
&mut RwTxn
with, a less restrictive,&RwTxn
.The text was updated successfully, but these errors were encountered: