Skip to content

Commit

Permalink
Revert "PostgreSQL: introduce transaction_active? rather than trackin…
Browse files Browse the repository at this point in the history
…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
FooBarWidget committed Nov 3, 2008
1 parent f48703e commit e383835
Showing 1 changed file with 0 additions and 38 deletions.
Expand Up @@ -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
Expand Down

0 comments on commit e383835

Please sign in to comment.