sig
  type oid = int
  type large_object
  module FFormat : sig type t = TEXT | BINARY end
  type ftype =
      BOOL
    | BYTEA
    | CHAR
    | NAME
    | INT8
    | INT2
    | INT2VECTOR
    | INT4
    | REGPROC
    | TEXT
    | OID
    | TID
    | XID
    | CID
    | OIDVECTOR
    | POINT
    | LSEG
    | PATH
    | BOX
    | POLYGON
    | LINE
    | FLOAT4
    | FLOAT8
    | ABSTIME
    | RELTIME
    | TINTERVAL
    | UNKNOWN
    | CIRCLE
    | CASH
    | MACADDR
    | INET
    | CIDR
    | ACLITEM
    | BPCHAR
    | VARCHAR
    | DATE
    | TIME
    | TIMESTAMP
    | TIMESTAMPTZ
    | INTERVAL
    | TIMETZ
    | BIT
    | VARBIT
    | NUMERIC
    | REFCURSOR
    | REGPROCEDURE
    | REGOPER
    | REGOPERATOR
    | REGCLASS
    | REGTYPE
    | RECORD
    | CSTRING
    | ANY
    | ANYARRAY
    | VOID
    | TRIGGER
    | LANGUAGE_HANDLER
    | INTERNAL
    | OPAQUE
    | ANYELEMENT
  type result_status =
      Empty_query
    | Command_ok
    | Tuples_ok
    | Copy_out
    | Copy_in
    | Bad_response
    | Nonfatal_error
    | Fatal_error
  type getline_result = EOF | LineRead | BufFull
  type getline_async_result =
      EndOfData
    | NoData
    | DataRead of int
    | PartDataRead of int
  type seek_cmd = SEEK_SET | SEEK_CUR | SEEK_END
  type error =
      Field_out_of_range of int * int
    | Tuple_out_of_range of int * int
    | Binary
    | Connection_failure of string
    | Unexpected_status of Postgresql.result_status * string *
        Postgresql.result_status list
  exception Error of Postgresql.error
  val string_of_error : Postgresql.error -> string
  exception Oid of Postgresql.oid
  val escape_string : ?pos:int -> ?len:int -> string -> string
  external unescape_bytea : string -> string = "PQunescapeBytea_stub"
  external ftype_of_oid : Postgresql.oid -> Postgresql.ftype
    = "ftype_of_oid_stub"
  external oid_of_ftype : Postgresql.ftype -> Postgresql.oid
    = "oid_of_ftype_stub"
  val string_of_ftype : Postgresql.ftype -> string
  val ftype_of_string : string -> Postgresql.ftype
  external result_status : Postgresql.result_status -> string
    = "PQresStatus_stub"
  val invalid_oid : Postgresql.oid
  class type result =
    object
      method binary_tuples : bool
      method cmd_status : string
      method cmd_tuples : string
      method error : string
      method fformat : int -> Postgresql.FFormat.t
      method fmod : int -> int
      method fname : int -> string
      method fnumber : string -> int
      method fsize : int -> int
      method ftype : int -> Postgresql.ftype
      method get_all : string array array
      method get_all_lst : string list list
      method get_fnames : string array
      method get_fnames_lst : string list
      method get_tuple : int -> string array
      method get_tuple_lst : int -> string list
      method getisnull : int -> int -> bool
      method getlength : int -> int -> int
      method getvalue : int -> int -> string
      method nfields : int
      method ntuples : int
      method oid_value : Postgresql.oid
      method status : Postgresql.result_status
    end
  type connection_status = Ok | Bad
  type conninfo_option = {
    cio_keyword : string;
    cio_envvar : string;
    cio_compiled : string option;
    cio_val : string option;
    cio_label : string;
    cio_dispchar : string;
    cio_dispsize : int;
  }
  external conndefaults : unit -> Postgresql.conninfo_option array
    = "PQconndefaults_stub"
  class connection :
    ?host:string ->
    ?hostaddr:string ->
    ?port:string ->
    ?dbname:string ->
    ?user:string ->
    ?password:string ->
    ?options:string ->
    ?tty:string ->
    ?requiressl:string ->
    ?conninfo:string ->
    unit ->
    object
      method backend_pid : int
      method consume_input : unit
      method copy_in_channel : Pervasives.in_channel -> unit
      method copy_out : (string -> unit) -> unit
      method copy_out_channel : Pervasives.out_channel -> unit
      method db : string
      method empty_result : Postgresql.result_status -> Postgresql.result
      method endcopy : unit
      method error_message : string
      method escape_bytea : ?pos:int -> ?len:int -> string -> string
      method exec :
        ?expect:Postgresql.result_status list -> string -> Postgresql.result
      method finish : unit
      method flush : unit
      method get_result : Postgresql.result option
      method getline :
        ?pos:int -> ?len:int -> string -> Postgresql.getline_result
      method getline_async :
        ?pos:int -> ?len:int -> string -> Postgresql.getline_async_result
      method host : string
      method is_busy : bool
      method is_nonblocking : bool
      method lo_close : Postgresql.large_object -> unit
      method lo_creat : Postgresql.oid
      method lo_export : Postgresql.oid -> string -> unit
      method lo_import : string -> Postgresql.oid
      method lo_open : Postgresql.oid -> Postgresql.large_object
      method lo_read :
        Postgresql.large_object -> ?pos:int -> ?len:int -> string -> int
      method lo_seek :
        ?pos:int ->
        ?whence:Postgresql.seek_cmd -> Postgresql.large_object -> unit
      method lo_tell : Postgresql.large_object -> int
      method lo_unlink : Postgresql.oid -> unit
      method lo_write :
        ?pos:int -> ?len:int -> string -> Postgresql.large_object -> unit
      method notifies : (string * int) option
      method options : string
      method pass : string
      method port : string
      method putline : string -> unit
      method putnbytes : ?pos:int -> ?len:int -> string -> unit
      method request_cancel : unit
      method reset : unit
      method send_query : string -> unit
      method set_nonblocking : bool -> unit
      method set_notice_processor : (string -> unit) -> unit
      method socket : Unix.file_descr
      method status : Postgresql.connection_status
      method try_reset : unit
      method tty : string
      method user : string
    end
end