# File lib/dbd/pg/database.rb, line 40
40:     def initialize(dbname, user, auth, attr)
41:         hash = DBI::Utils.parse_params(dbname)
42: 
43:         if hash['dbname'].nil? and hash['database'].nil?
44:             raise DBI::InterfaceError, "must specify database"
45:         end
46: 
47:         hash['options'] ||= nil
48:         hash['tty'] ||= ''
49:         hash['port'] = hash['port'].to_i unless hash['port'].nil? 
50: 
51:         @connection = PGconn.new(hash['host'], hash['port'], hash['options'], hash['tty'], 
52:                                  hash['dbname'] || hash['database'], user, auth)
53: 
54:         @exec_method = :exec
55:         @in_transaction = false
56: 
57:         # set attribute defaults, and look for pg_* attrs in the DSN
58:         @attr = { 'AutoCommit' => true, 'pg_async' => false }
59:         hash.each do |key, value|
60:             @attr[key] = value if key =~ /^pg_./
61:         end
62:         @attr.merge!(attr || {})
63:         if @attr['pg_async'].is_a?(String)
64:             case @attr['pg_async'].downcase
65:             when 'true'
66:                 @attr['pg_async'] = true
67:             when 'false'
68:                 @attr['pg_async'] = false
69:             else
70:                 raise InterfaceError, %q{'pg_async' must be 'true' or 'false'}
71:             end
72:         end
73: 
74:         @attr.each { |k,v| self[k] = v} 
75:         @attr["pg_native_binding"] = true unless @attr.has_key? "pg_native_binding"
76: 
77:         @type_map = __types
78: 
79:         self['AutoCommit'] = true    # Postgres starts in unchained mode (AutoCommit=on) by default 
80: 
81:     rescue PGError => err
82:         raise DBI::OperationalError.new(err.message)
83:     end