Rework context cancellation. #251
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based in #250.
Fixes an issue described there where a setting a context that cancels while stepping a given statement, interrupts other partially stepped statements on the same connection that were not stepped while the "interrupt" was active. This better matches the semantics of context cancellation in
database/sql
, and avoids some pitfalls with the previous method.It still probably causes issues with recursive usages of step/prepare (virtual tables that step/prepare while being stepped), but that's much rarer: none of the current implementations set their own interrupts.
It can be argued that
Get
/SetInterrupt
is the wrong name, but I'm keeping it, at least for now: the context is just for interruption so cancellation works; I don't want to give the impression that it should be used for anything else, because it still violates Go expectations by being stored in a struct. Also the error returned issqlite3.INTERRUPT
in all cases, so that makes sense. It's not worth breaking compatibility if we're not 100% sure we can have a better name.