Permalink
Browse files

Revert "PostgreSQL: introduce transaction_active? rather than trackin…

…g activity ourselves"

This commit conflicts with savepoint support.

This reverts commit 045713e.

Conflicts:

	activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  • Loading branch information...
1 parent f48703e commit e383835e738a30cd992c322eff126380bd15094f @FooBarWidget FooBarWidget committed Oct 9, 2008
Showing with 0 additions and 38 deletions.
  1. +0 −38 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
38 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -529,44 +529,6 @@ def rollback_db_transaction
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

0 comments on commit e383835

Please sign in to comment.