Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support prepared transactions/two-phase commit on PostgreSQL, MySQL, …
…and H2 This commit enables you to use prepared transactions using the :prepare option to Database#transaction. The :prepare option value should be some transaction id string, which is used in the SQL query when preparing a transaction. On PostgreSQL and MySQL, it is literalized as an SQL string, while on H2, it is used literally. Setting up a prepared transaction is fairly easy: DB.transaction(:prepare=>'some_transaction_id_string') do ... end One a prepared transaction has been set up, it can be commited using commit_prepared_transaction: DB.commit_prepared_transaction('some_transaction_id_string') or rolled back with rollback_prepared_transaction: DB.rollback_prepared_transaction('some_transaction_id_string') Note that if the transaction block itself rolls back the transaction (by raising an exception), neither commit_prepared_transaction or rollback_prepared_transaction will work. In order to support prepared transactions, the Database private instance methods _transaction, begin_transaction, commit_transaction, and rollback_transaction all take an optional options hash. External adapters, even if they don't support prepared transactions, must add an optional options hash to their implementation of these methods or they will probably break. This commit modifies all built-in adapters have already to support this new API. This commit also modifies the H2 JDBC subadapter to support savepoints.
- Loading branch information
1 parent
b938370
commit dc1ac38
Showing
14 changed files
with
182 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.