Skip to content
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

feat: add support for nested transaction rollbacks via savepoints in sql #4375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Nov 27, 2024

  1. feat: add support for nested transaction rollbacks via savepoints in sql

    This is my first OSS contribution for a Rust project, so I'm sure I've
    made some stupid mistakes, but I think it should mostly work :)
    
    This change adds a mutable depth counter, that can track how many levels
    deep a transaction is, and uses savepoints to implement correct rollback
    behaviour. Previously, once a nested transaction was complete, it would
    be saved with `COMMIT`, meaning that even if the outer transaction was
    rolled back, the operations in the inner transaction would persist. With
    this change, if the outer transaction gets rolled back, then all inner
    transactions will also be rolled back.
    
    Different flavours of SQL servers have different syntax for handling
    savepoints, so I've had to add new methods to the `Queryable` trait for
    getting the commit and rollback statements. These are both parameterized
    by the current depth.
    
    I've additionally had to modify the `begin_statement` method to accept a depth
    parameter, as it will need to conditionally create a savepoint.
    
    When opening a transaction via the transaction server, you can now pass
    the prior transaction ID to re-use the existing transaction,
    incrementing the depth.
    
    Signed-off-by: Lucian Buzzo <[email protected]>
    LucianBuzzo committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    0306f10 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8f090ee View commit details
    Browse the repository at this point in the history