class Connection
Definitions
def status
Return the status of the connection.
Implementation
def status
Native.status(self)
end
def error_message
Return the last error message.
Implementation
def error_message
Native.error_message(self)
end
def socket
Return the underlying socket used for IO.
Implementation
def socket
Native.socket(self)
end
def close
Close the connection.
Implementation
def close
Native.finish(self)
@io.close
end
def discard_results
Silently discard any results that application didn't read.
Implementation
def discard_results
while result = self.get_result
status = Native.result_status(result)
Native.clear(result)
case status
when :copy_in
self.put_copy_end("Discard results")
when :copy_out
self.flush_copy_out
end
end
return nil
end
def flush
After sending any command or data on a nonblocking connection, call PQflush. If it returns 1, wait for the socket to become read- or write-ready. If it becomes write-ready, call PQflush again. If it becomes read-ready, call PQconsumeInput, then call PQflush again. Repeat until PQflush returns 0. (It is necessary to check for read-ready and drain the input with PQconsumeInput, because the server can block trying to send us data, e.g. NOTICE messages, and won't read our data until we read its.) Once PQflush returns 0, wait for the socket to be read-ready and then read the response as described above.
Implementation
def flush
while true
case Native.flush(self)
when 1
@io.wait_any
check! Native.consume_input(self)
when 0
return
end
end
end