Class Sequel::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 145
145:       def apply_connection_settings
146:         super
147:         if Postgres.use_iso_date_format
148:           sql = "SET DateStyle = 'ISO'"
149:           execute(sql)
150:         end
151:         @prepared_statements = {} if SEQUEL_POSTGRES_USES_PG
152:       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 156
156:       def check_disconnect_errors
157:         begin
158:           yield
159:         rescue PGError =>e
160:           begin
161:             s = status
162:           rescue PGError
163:             raise Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)
164:           end
165:           status_ok = (s == Adapter::CONNECTION_OK)
166:           status_ok ? raise : raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError))
167:         ensure
168:           block if status_ok
169:         end
170:       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 174
174:       def execute(sql, args=nil)
175:         q = check_disconnect_errors{@db.log_yield(sql, args){args ? async_exec(sql, args) : async_exec(sql)}}
176:         begin
177:           block_given? ? yield(q) : q.cmd_tuples
178:         ensure
179:           q.clear
180:         end
181:       end

[Validate]