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(database): add support for nested transactions using savepoints #8833

Open
wants to merge 16 commits into
base: 4.6
Choose a base branch
from

Commits on May 16, 2024

  1. test(transaction): add some test cases for nested transactions

    Test whether we can start two nested transactions ...
    
    1. ... complete them and see the result in the database
    2. ... rollback the outer one after completing the inner one,
       and see that the result is _not_ in the database.
    3. ... roll back the inner one and see if the result
          of the outer one is in the database after completing.
    mkuettel committed May 16, 2024
    Configuration menu
    Copy the full SHA
    4bf87b1 View commit details
    Browse the repository at this point in the history
  2. feat(database): add option enableNestedTransactions to BaseConnection

    This option will be false by default, so the previous documented
    behaviour of CodeIgniter gets kept & to avoid introducing a breaking
    change.
    
    CodeIgniter allows for nesting transactions, but only ever cared about,
    actually committing/rolling back the most outer one. This commit keeps
    this behaviour by default, but adds the database driver option
    'enableNestedTransactions' to the BaseConnection.
    
    When set to true, codeigniter now will call
    _transBeginNested()/_transCommitNested()/_transRollbackNested() on the
    respective driver implemented, when further transactions are nested into
    the outermost transaction.
    mkuettel committed May 16, 2024
    Configuration menu
    Copy the full SHA
    287ad8f View commit details
    Browse the repository at this point in the history
  3. feat(database): add support for nested transactions using savepoints

    By using SAVEPOINT SQL statements to manage transactions deeper than 1 level,
    it's possible to provide full nested transaction semantics for the
    following drivers:
    
    - SQLite3:
      - https://sqlite.org/lang_transaction.html
      - Savepoints: https://sqlite.org/lang_savepoint.html
    - MySQLi
      - https://mariadb.com/kb/en/savepoint/
    - Postgre
      - https://www.postgresql.org/docs/current/sql-savepoint.html
    
    The implementation starts a transaction when transBegin() is first called as before.
    But then all nested transactions will be managed by creating,
    releasing (commiting) or rolling back savepoint.
    Only when the outermost transaction is completed a COMMIT or ROLLBACK
    will be executed, either committing the transaction and all inner
    _committed_ transactions, or rolling everything back.
    
    This feature is currently disabled for SQLSrv & OCI8 and they keep on.
    working with just 1 transaction layer & nested ones getting ignored.
    
    Revert "feat(sqlite3): add support for nested transactions using SAVEPOINT"
    
    This reverts commit 47db608.
    
    feat(database): use savepoints for nested transactions for MySQLi, SQLite3 + Postgre driver
    mkuettel committed May 16, 2024
    Configuration menu
    Copy the full SHA
    7a9f89c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    277b505 View commit details
    Browse the repository at this point in the history
  5. tests(transaction): add more test cases for when transaction nesting …

    …is enabled, plus an extreme example
    mkuettel committed May 16, 2024
    Configuration menu
    Copy the full SHA
    9015529 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    92f5094 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    4a9aca8 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    98e9702 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    48e3742 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d5c99bd View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    f531ef2 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    f5b5fed View commit details
    Browse the repository at this point in the history
  13. format: run php-cs-fixer

    mkuettel committed May 16, 2024
    Configuration menu
    Copy the full SHA
    6970c48 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    f35c71f View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    c0285f2 View commit details
    Browse the repository at this point in the history
  16. format: run php-cs-fixer

    mkuettel committed May 16, 2024
    Configuration menu
    Copy the full SHA
    4bf49f9 View commit details
    Browse the repository at this point in the history