-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add progress handler support to sqlite #2256
Conversation
6cf15b0
to
eade49c
Compare
@nbaztec major refactors have landed on |
@abonander Done |
@nbaztec Github is still saying that there's merge conflicts but won't say what they are. Can you try actually rebasing and not just merging |
eee2ab0
to
608d00c
Compare
@abonander Done |
@nbaztec |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it's taken me this long to get to, but unfortunately this PR has several instances of possible undefined behavior that need to be addressed.
Additionally, I think it's worth discussing the actual use-cases for setting a progress handler and if we can design an API that's better tailored to them.
The main motivation of the feature would be to enable long-running queries to be interrupted within a reasonable time-frame. As of now, there's no way to abort a SQLite query that is running for a long while. Thanks for the good review comments. I'd suggest we store the handler within the And definitely a good point about catching the panic. Makes sense to use extern "C" fn progress_callback<F>(callback: *mut c_void) -> c_int
where
F: FnMut() -> bool,
{
unsafe {
let r = catch_unwind(|| {
let boxed_callback: *mut F = callback.cast::<F>();
(*boxed_callback)()
});
c_int::from(r.unwrap_or_default())
}
}
I saw this pattern being used in a bunch of other sqlite rust implementations like sqlite and rusqlite so reckoned it to be a "safe enough". |
That's probably still UB as I addressed in my follow-up comment. I would store it as |
It doesn't make sense to store it in the |
@abonander I tried to apply the changes but stumbled onto the problem that the |
@nbaztec |
Had some other problem - PEBKAC. Managed to remedy it. Please review the new code, happy to make any further improvements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pay close attention to what you're doing inside unsafe {}
blocks, and ensure to address all review comments this time.
* rebase main * fmt * use NonNull to fix UB * apply code suggestions * add test for multiple handler drops * remove nightly features for test
What
Adds progress handler support to sqlite. The feature is already supported by the sqlite driver. This PR exposes it.