Skip to content

Conversation

ncruces
Copy link
Owner

@ncruces ncruces commented Mar 25, 2025

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 is sqlite3.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.

@ncruces ncruces changed the title Discussion #250. Rework context cancellation. Mar 26, 2025
@ncruces ncruces marked this pull request as ready for review March 26, 2025 11:08
@ncruces ncruces merged commit 9486411 into main Mar 26, 2025
17 checks passed
@ncruces ncruces deleted the interrupt branch March 29, 2025 07:31
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.

1 participant