diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 9c5b4c9c79..e1793ba460 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -52,6 +52,24 @@ module ActiveRecord 'PostgreSQL' end + # Is this connection alive and ready for queries? + def active? + # TODO: postgres-pr doesn't have PGconn#status. + if @connection.respond_to?(:status) + @connection.status != PGconn::CONNECTION_BAD + else + true + end + end + + # Close then reopen the connection. + def reconnect! + # TODO: postgres-pr doesn't have PGconn#reset. + if @connection.respond_to?(:reset) + @connection.reset + end + end + def native_database_types { :primary_key => "serial primary key", |