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

Constants

DISCONNECT_ERROR_RE = /\Acould not receive data from server/

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

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 122
122:       def check_disconnect_errors
123:         begin
124:           yield
125:         rescue PGError => e
126:           disconnect = false
127:           begin
128:             s = status
129:           rescue PGError
130:             disconnect = true
131:           end
132:           status_ok = (s == Adapter::CONNECTION_OK)
133:           disconnect ||= !status_ok
134:           disconnect ||= e.message =~ DISCONNECT_ERROR_RE
135:           disconnect ? raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)) : raise
136:         ensure
137:           block if status_ok && !disconnect
138:         end
139:       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 143
143:       def execute(sql, args=nil)
144:         args = args.map{|v| @db.bound_variable_arg(v, self)} if args
145:         q = check_disconnect_errors{execute_query(sql, args)}
146:         begin
147:           block_given? ? yield(q) : q.cmd_tuples
148:         ensure
149:           q.clear if q && q.respond_to?(:clear)
150:         end
151:       end

[Validate]