Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the restrictive &mut RwTxn by less restrictive &RwTxn #190

Closed
wants to merge 6 commits into from

Conversation

Kerollmops
Copy link
Member

@Kerollmops Kerollmops commented Jul 21, 2023

The PR fixes #189 by removing all of the &mut RwTxn requirements by simple &RwTxn. If you want to understand the new possibilities I advise you to look at the example showcase non-mutable-rwtxn.

Doing so allows very cool use cases like:

  • being able to dump database entries into another one.
  • write into a database with values from the same database.
  • Should we also use a &RwTxn when creating databases?
let wtxn = env.write_txn()?;
for result in database1.iter(&wtxn)? {
    let (k, v) = result?;
    database2.put(&wtxn, k, v)?; // It now compiles and works perfectly 🎉
}

@Kerollmops Kerollmops added this to the v0.20.0 milestone Jul 21, 2023
@Kerollmops Kerollmops changed the title Replace the &mut RwTxn by &RwTxn Replace the restrictive &mut RwTxn by less restrictive &RwTxn Jul 21, 2023
@Kerollmops Kerollmops marked this pull request as ready for review July 21, 2023 15:31
@Kerollmops
Copy link
Member Author

Closed because it is unsafe to implement it like that. We must consider a more restrictive way to let users copy the content from one database into another.

@Kerollmops Kerollmops closed this Apr 25, 2024
@Kerollmops Kerollmops deleted the no-more-mut-rwtxn branch April 25, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We can't write the entries of one database into another
1 participant