Parent

Class/Module Index [+]

Quicksearch

Sequel::Postgres::Adapter

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

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 122
def check_disconnect_errors
  begin
    yield
  rescue PGError => e
    disconnect = false
    begin
      s = status
    rescue PGError
      disconnect = true
    end
    status_ok = (s == Adapter::CONNECTION_OK)
    disconnect ||= !status_ok
    disconnect ||= e.message =~ DISCONNECT_ERROR_RE
    disconnect ? raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)) : raise
  ensure
    block if status_ok && !disconnect
  end
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 143
def execute(sql, args=nil)
  args = args.map{|v| @db.bound_variable_arg(v, self)} if args
  q = check_disconnect_errors{execute_query(sql, args)}
  begin
    block_given? ? yield(q) : q.cmd_tuples
  ensure
    q.clear if q && q.respond_to?(:clear)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.