Permalink
Browse files

Need to close template1 connection

  • Loading branch information...
1 parent 2391358 commit db7adba97b03123128cc5961767230132ed00ac2 @baloo baloo committed Mar 1, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 libraries/provider_database_postgresql.rb
@@ -84,10 +84,14 @@ def action_query
private
def exists?
- Chef::Log.debug("#{@new_resource}: checking if database #{@new_resource.database_name} exists")
- ret = db("template1").query("select * from pg_database where datname = '#{@new_resource.database_name}'").num_tuples != 0
- ret ? Chef::Log.debug("#{@new_resource}: database #{@new_resource.database_name} exists") :
- Chef::Log.debug("#{@new_resource}: database #{@new_resource.database_name} does not exist")
+ begin
+ Chef::Log.debug("#{@new_resource}: checking if database #{@new_resource.database_name} exists")
+ ret = db("template1").query("select * from pg_database where datname = '#{@new_resource.database_name}'").num_tuples != 0
+ ret ? Chef::Log.debug("#{@new_resource}: database #{@new_resource.database_name} exists") :
+ Chef::Log.debug("#{@new_resource}: database #{@new_resource.database_name} does not exist")
+ ensure
+ close
+ end
ret
end

0 comments on commit db7adba

Please sign in to comment.