-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fix a bunch of SQLite-related bugs #2866
Merged
Merged
+576
−74
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kentonv
force-pushed
the
kenton/sqlite-bugs
branch
from
October 8, 2024 22:49
3dafed7
to
b3fe27f
Compare
anonrig
reviewed
Oct 9, 2024
jasnell
approved these changes
Oct 9, 2024
justin-mp
approved these changes
Oct 9, 2024
kentonv
force-pushed
the
kenton/sqlite-bugs
branch
from
October 10, 2024 16:39
e1766f9
to
ed88b15
Compare
…ly threw. `Query`'s destructor didn't run in this case, so the statement was never reset, and trying to use it again would fail with SQLITE_MISUSE.
We are doing other per-statement cleanup in `destroy()`, makes sense to reset row counters here too, rather than on the next query constructor.
This commit has no functional change, but changes prepareSql() to return a struct containing the statement and other information which must be kept with the statement. At present there is no other information, but the next commit will add a description of the statement's effects on the transaction stack. I split this into a separate commit because it's a noisy mechanical change, which I wanted to keep separate from the actual logic change.
This registers a callback which will be called if the current transaction scope ends up being rolled back. We'll need this to fix bugs elsewhere. The implementation requires that we keep track of the transaction stack, which is a bit of a pain. We can discover which statements affect the transaction stack via the authorizor callback.
The state of the `SqliteKv` object could get out-of-sync in the case of rollbacks. Our new `onRollback()` function makes this easy to deal with.
Also if cached alarm changes are rolled back. This replaces the previous invalidation mechanism, which did not properly handle `transactionSync()`. The new mechanism handles all rollbacks, so we don't need the old mechanism at all anymore.
…ION. People mistakenly believed that we didn't support transactions!
`ROLLBACK TO` does not release the savepoint, just rolls back to the point immediately after the savepoint was created. We must additionally release it. This never caused a problem becaues: 1. `transactionSync()` always runs inside an implicit transaction. Committing or rolling back the implicit transaction implicitly releases all the savepoints. 2. It turns out SQLite allows savepoints with the same name as previous ones. The name always refers to the most-recent savepoint by that name which hasn't been released. So, the "leaked" savepoint didn't prevent a new savepoint with the same name from being created later. Note that the async version of `transaction()` does release savepoints properly. I also added a TODO to take advantage of the fact that savepoints can have the same name...
kentonv
force-pushed
the
kenton/sqlite-bugs
branch
from
October 10, 2024 16:47
ed88b15
to
d34205c
Compare
windows build failure unrelated; fixed in #2891 |
kentonv
added a commit
that referenced
this pull request
Oct 11, 2024
…dy in a transaction?` Bug introduced in #2866. See comments for explanation.
kentonv
added a commit
that referenced
this pull request
Oct 11, 2024
…dy in a transaction?` Bug introduced in #2866. See comments for explanation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
BEGIN TRANSACTION
. The "not authorized" error confused people into thinking that transactions weren't supported!RELEASE
of savepoints intransactionSync()
, although in practice I think it didn't cause any actual problem (see commit description).