Parent

Class Index [+]

Quicksearch

Sequel::Adapter

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

Constants

DISCONNECT_ERROR_RE

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

check_disconnect_errors() click to toggle source

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

     # File lib/sequel/adapters/postgres.rb, line 166
166:       def check_disconnect_errors
167:         begin
168:           yield
169:         rescue PGError =>e
170:           disconnect = false
171:           begin
172:             s = status
173:           rescue PGError
174:             disconnect = true
175:           end
176:           status_ok = (s == Adapter::CONNECTION_OK)
177:           disconnect ||= !status_ok
178:           disconnect ||= e.message =~ DISCONNECT_ERROR_RE
179:           disconnect ? raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)) : raise
180:         ensure
181:           block if status_ok
182:         end
183:       end
execute(sql, args=nil) click to toggle source

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

     # File lib/sequel/adapters/postgres.rb, line 187
187:       def execute(sql, args=nil)
188:         args = args.map{|v| @db.bound_variable_arg(v, self)} if args
189:         q = check_disconnect_errors{execute_query(sql, args)}
190:         begin
191:           block_given? ? yield(q) : q.cmd_tuples
192:         ensure
193:           q.clear if q
194:         end
195:       end

Private Instance Methods

execute_query(sql, args) click to toggle source

Return the PGResult object that is returned by executing the given sql and args.

     # File lib/sequel/adapters/postgres.rb, line 201
201:       def execute_query(sql, args)
202:         @db.log_yield(sql, args){args ? async_exec(sql, args) : async_exec(sql)}
203:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.