Class Sequel::Postgres::Adapter
In: lib/sequel/adapters/postgres.rb
Parent: ::PGconn

PGconn subclass for connection specific methods used with the pg, postgres, or postgres-pr driver.

Methods

Included Modules

Sequel::Postgres::AdapterMethods

Attributes

prepared_statements  [R]  Hash of prepared statements for this connection. Keys are string names of the server side prepared statement, and values are SQL strings.

Public Instance methods

Apply connection settings for this connection. Current sets the date style to ISO in order make Date object creation in ruby faster, if Postgres.use_iso_date_format is true.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 132
132:       def apply_connection_settings
133:         super
134:         if Postgres.use_iso_date_format
135:           sql = "SET DateStyle = 'ISO'"
136:           execute(sql)
137:         end
138:         @prepared_statements = {} if SEQUEL_POSTGRES_USES_PG
139:       end

Raise a Sequel::DatabaseDisconnectError if a PGError is raised and the connection status cannot be determined or it is not OK.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 143
143:       def check_disconnect_errors
144:         begin
145:           yield
146:         rescue PGError =>e
147:           begin
148:             s = status
149:           rescue PGError
150:             raise Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)
151:           end
152:           status_ok = (s == Adapter::CONNECTION_OK)
153:           status_ok ? raise : raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError))
154:         ensure
155:           block if status_ok
156:         end
157:       end

Execute the given SQL with this connection. If a block is given, yield the results, otherwise, return the number of changed rows.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 161
161:       def execute(sql, args=nil)
162:         q = check_disconnect_errors{@db.log_yield(sql, args){args ? async_exec(sql, args) : async_exec(sql)}}
163:         begin
164:           block_given? ? yield(q) : q.cmd_tuples
165:         ensure
166:           q.clear
167:         end
168:       end

[Validate]