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

0.9.1 - #transaction may wrongly end enclosing transaction #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jan 10, 2011

  1. Make #transaction check nested tx depth before implicit COMMIT/ROLLBACK.

    Previously, #transaction only checked to see that it was inside *any* tx
    before ending (COMMIT/ROLLBACK) the open tx.  However, the ability of users
    to explicitly end a tx inside the block means that the #transaction block
    might end in an enclosing tx wherein the implicit COMMIT/ROLLBACK behavior
    intended for the *nested* transaction is incorrect.
    
    Example:
    
        dbh.transaction do |dbh|   # tx depth 1
          dbh.execute(STMT_1)
          dbh.transaction do |dbh| # tx depth 2
            dbh.execute(STMT_2)
            dbh.commit             # tx depth 1 (#rollback would do the same)
          end                      # tx depth 0 (implicit COMMIT -- to early)
          dbh.execute(STMT_3)
        end                        # implicit COMMIT of STMT_3 ignored!
                                   # explicit would have been ignored, too
    pilcrow committed Jan 10, 2011
    Copy the full SHA
    a1ef450 View commit details
    Browse the repository at this point in the history