diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-10-09 14:47:43 +0200 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-11-03 20:56:00 +0100 |
commit | e383835e738a30cd992c322eff126380bd15094f (patch) | |
tree | a963b5332f484d8ec5f77d4629797c44da68d418 /activerecord | |
parent | f48703e8c6ad8497795a67708ace4eb507a91119 (diff) | |
download | rails-e383835e738a30cd992c322eff126380bd15094f.tar.gz rails-e383835e738a30cd992c322eff126380bd15094f.tar.bz2 rails-e383835e738a30cd992c322eff126380bd15094f.zip |
Revert "PostgreSQL: introduce transaction_active? rather than tracking activity ourselves"
This commit conflicts with savepoint support.
This reverts commit 045713ee240fff815edb5962b25d668512649478.
Conflicts:
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index f34093f0ff..98501db816 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -529,44 +529,6 @@ module ActiveRecord execute "ROLLBACK" end - # ruby-pg defines Ruby constants for transaction status, - # ruby-postgres does not. - PQTRANS_IDLE = defined?(PGconn::PQTRANS_IDLE) ? PGconn::PQTRANS_IDLE : 0 - - # Check whether a transaction is active. - def transaction_active? - @connection.transaction_status != PQTRANS_IDLE - end - - # Wrap a block in a transaction. Returns result of block. - def transaction(start_db_transaction = true) - transaction_open = false - begin - if block_given? - if start_db_transaction - begin_db_transaction - transaction_open = true - end - yield - end - rescue Exception => database_transaction_rollback - if transaction_open && transaction_active? - transaction_open = false - rollback_db_transaction - end - raise unless database_transaction_rollback.is_a? ActiveRecord::Rollback - end - ensure - if transaction_open && transaction_active? - begin - commit_db_transaction - rescue Exception => database_transaction_rollback - rollback_db_transaction - raise - end - end - end - def create_savepoint execute("SAVEPOINT #{current_savepoint_name}") end |