-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
Savepoint support #61
Comments
Side-note: It doesn't look like the sqlite3_rollback_hook gets called for If so, this impacts any TransactionObservers in the event that savepoints are used. (They will receive databaseDidChangeWithEvent for any changes in a savepoint, but will not receive databaseDidRollback if a rollback to savepoint is executed for any reason.) |
Hi again, @swiftlyfalling Thanks for the suggestion. Consider it on the TODO list. I like your documented code snippet which makes things clear. And particularly the automatic rollback of savepoints on error: that's handy. I discover savepoints, actually: I haven't used them yet. I'll have to look at the savepoints API of a couple of other libraries, like http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html. Until then, you can use savepoints with raw SQL: try db.execute("SAVEPOINT foo")
Well spotted! No real surprise here: transaction hooks are for transactions that write on disk, when savepoints can be seen as "marks" in transactions' timelines.
That's so true. We could:
|
Note to myself on how to provide robust support for savepoints even when user executes raw SQL statements and does not use high-level APIs: savepoints statements can be identified by StatementCompilationObserver:
|
…ransaction observer’s databaseDidChangeWithEvent callback.
@swiftlyfalling: until I add savepoint APIs to GRDB, I've fixed the current state of the lib: events that are rollbacked by a savepoint are never notified to observers. See d57107c |
Sane interaction of transaction observer and savepoints has shipped in v0.69.0. |
…o purpose forcing the user to name them: use a single default savepoint name. And provide thorough testing.
... and |
What are your thoughts on adding support for SAVEPOINT within Transactions?
Perhaps something like:
The text was updated successfully, but these errors were encountered: