# src/db_connector/postgres

Theme:

- Manual
- Standard library
- Index
- Compiler docs
- Fusion docs
- devel, stable

Search:

# Types

    ConnStatusType = enum
      CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE,
      CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV,
      CONNECTION_SSL_STARTUP, CONNECTION_NEEDED, CONNECTION_CHECK_WRITABLE,
      CONNECTION_CONSUME, CONNECTION_GSS_STARTUP, CONNECTION_CHECK_TARGET

    ExecStatusType = enum
      PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT,
      PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR,
      PGRES_COPY_BOTH, PGRES_SINGLE_TUPLE

    Oid = int32

    PConnStatusType = ptr ConnStatusType

    PExecStatusType = ptr ExecStatusType

    PGconn {.pure, final.} = object
      pghost*: cstring
      pgtty*: cstring
      pgport*: cstring
      pgoptions*: cstring
      dbName*: cstring
      status*: ConnStatusType
      errorMessage*: array[0 .. 4096 - 1, char]
      Pfin*: File
      Pfout*: File
      Pfdebug*: File
      sock*: int32
      laddr*: SockAddr
      raddr*: SockAddr
      salt*: array[0 .. 2 - 1, char]
      asyncNotifyWaiting*: int32
      notifyList*: pointer
      pguser*: cstring
      pgpass*: cstring
      lobjfuncs*: PPGlobjfuncs

    PGlobjfuncs {.pure, final.} = object
      fn_lo_open*: Oid
      fn_lo_close*: Oid
      fn_lo_creat*: Oid
      fn_lo_unlink*: Oid
      fn_lo_lseek*: Oid
      fn_lo_tell*: Oid
      fn_lo_read*: Oid
      fn_lo_write*: Oid

    pgNotify {.pure, final.} = object
      relname*: cstring
      be_pid*: int32
      extra*: cstring

    PGresAttDesc {.pure, final.} = object
      name*: cstring
      adtid*: Oid
      adtsize*: int

    PGresAttValue {.pure, final.} = object
      length*: int32
      value*: cstring

    PGresult {.pure, final.} = object
      ntups*: int32
      numAttributes*: int32
      attDescs*: PPGresAttDesc
      tuples*: PPPGresAttValue
      tupArrSize*: int32
      resultStatus*: ExecStatusType
      cmdStatus*: array[0 .. 40 - 1, char]
      binary*: int32
      conn*: PPGconn

    PGTransactionStatusType = enum
      PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR,
      PQTRANS_UNKNOWN

    PGVerbosity = enum
      PQERRORS_TERSE, PQERRORS_DEFAULT, PQERRORS_VERBOSE, PQERRORS_SQLSTATE

    POid = ptr Oid

    PostgresPollingStatusType = enum
      PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING,
      PGRES_POLLING_OK, PGRES_POLLING_ACTIVE

    PPGconn = ptr PGconn

    PPGlobjfuncs = ptr PGlobjfuncs

    PPGNotify = ptr pgNotify

    PPGresAttDesc = ptr PGresAttDesc

    PPGresAttValue = ptr PGresAttValue

    PPGresult = ptr PGresult

    PPGTransactionStatusType = ptr PGTransactionStatusType

    PPGVerbosity = ptr PGVerbosity

    PPostgresPollingStatusType = ptr PostgresPollingStatusType

    PPPGresAttDesc = ptr PPGresAttDesc

    PPPGresAttValue = ptr PPGresAttValue

    PPQArgBlock = ptr PQArgBlock

    Ppqbool = ptr pqbool

    PPQconninfoOption = ptr PQconninfoOption

    PPQprintOpt = ptr PQprintOpt

    PQArgBlock {.pure, final.} = object
      length*: int32
      isint*: int32
      p*: pointer

    pqbool = char

    PQconninfoOption {.pure, final.} = object
      keyword*: cstring
      envvar*: cstring
      compiled*: cstring
      val*: cstring
      label*: cstring
      dispchar*: cstring
      dispsize*: int32

    PQnoticeProcessor = proc (arg: pointer; message: cstring) {.cdecl.}

    PQnoticeReceiver = proc (arg: pointer; res: PPGresult) {.cdecl.}

    PQprintOpt {.pure, final.} = object
      header*: pqbool
      align*: pqbool
      standard*: pqbool
      html3*: pqbool
      expanded*: pqbool
      pager*: pqbool
      fieldSep*: cstring
      tableOpt*: cstring
      caption*: cstring
      fieldName*: ptr cstring

    SockAddr = array[1 .. 112, int8]

# Consts

    CMDSTATUS_LEN = 40

    ERROR_MSG_LENGTH = 4096

# Procs

    proc lo_close(conn: PPGconn; fd: int32): int32 {.cdecl, dynlib: dllName,
        importc: "lo_close", ...raises: [], tags: [], forbids: [].}

    proc lo_creat(conn: PPGconn; mode: int32): Oid {.cdecl, dynlib: dllName,
        importc: "lo_creat", ...raises: [], tags: [], forbids: [].}

    proc lo_export(conn: PPGconn; lobjId: Oid; filename: cstring): int32 {.cdecl,
        dynlib: dllName, importc: "lo_export", ...raises: [], tags: [], forbids: [].}

    proc lo_import(conn: PPGconn; filename: cstring): Oid {.cdecl, dynlib: dllName,
        importc: "lo_import", ...raises: [], tags: [], forbids: [].}

    proc lo_lseek(conn: PPGconn; fd: int32; offset: int32; whence: int32): int32 {.
        cdecl, dynlib: dllName, importc: "lo_lseek", ...raises: [], tags: [],
        forbids: [].}

    proc lo_open(conn: PPGconn; lobjId: Oid; mode: int32): int32 {.cdecl,
        dynlib: dllName, importc: "lo_open", ...raises: [], tags: [], forbids: [].}

    proc lo_read(conn: PPGconn; fd: int32; buf: cstring; length: int): int32 {.
        cdecl, dynlib: dllName, importc: "lo_read", ...raises: [], tags: [],
        forbids: [].}

    proc lo_tell(conn: PPGconn; fd: int32): int32 {.cdecl, dynlib: dllName,
        importc: "lo_tell", ...raises: [], tags: [], forbids: [].}

    proc lo_unlink(conn: PPGconn; lobjId: Oid): int32 {.cdecl, dynlib: dllName,
        importc: "lo_unlink", ...raises: [], tags: [], forbids: [].}

    proc lo_write(conn: PPGconn; fd: int32; buf: cstring; length: int): int32 {.
        cdecl, dynlib: dllName, importc: "lo_write", ...raises: [], tags: [],
        forbids: [].}

    proc pqbackendPID(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQbackendPID", ...raises: [], tags: [], forbids: [].}

    proc pqbinaryTuples(res: PPGresult): int32 {.cdecl, dynlib: dllName,
        importc: "PQbinaryTuples", ...raises: [], tags: [], forbids: [].}

    proc pqclear(res: PPGresult) {.cdecl, dynlib: dllName, importc: "PQclear",
                                   ...raises: [], tags: [], forbids: [].}

    proc pqclientEncoding(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQclientEncoding", ...raises: [], tags: [], forbids: [].}

    proc pqcmdStatus(res: PPGresult): cstring {.cdecl, dynlib: dllName,
        importc: "PQcmdStatus", ...raises: [], tags: [], forbids: [].}

    proc pqcmdTuples(res: PPGresult): cstring {.cdecl, dynlib: dllName,
        importc: "PQcmdTuples", ...raises: [], tags: [], forbids: [].}

    proc pqconndefaults(): PPQconninfoOption {.cdecl, dynlib: dllName,
        importc: "PQconndefaults", ...raises: [], tags: [], forbids: [].}

    proc pqconnectdb(conninfo: cstring): PPGconn {.cdecl, dynlib: dllName,
        importc: "PQconnectdb", ...raises: [], tags: [], forbids: [].}

    proc pqconnectionNeedsPassword(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQconnectionNeedsPassword", ...raises: [], tags: [], forbids: [].}

    proc pqconnectionUsedPassword(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQconnectionUsedPassword", ...raises: [], tags: [], forbids: [].}

    proc pqconnectPoll(conn: PPGconn): PostgresPollingStatusType {.cdecl,
        dynlib: dllName, importc: "PQconnectPoll", ...raises: [], tags: [], forbids: [].}

    proc pqconnectStart(conninfo: cstring): PPGconn {.cdecl, dynlib: dllName,
        importc: "PQconnectStart", ...raises: [], tags: [], forbids: [].}

    proc pqconninfoFree(connOptions: PPQconninfoOption) {.cdecl, dynlib: dllName,
        importc: "PQconninfoFree", ...raises: [], tags: [], forbids: [].}

    proc pqconsumeInput(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQconsumeInput", ...raises: [], tags: [], forbids: [].}

    proc pqdb(conn: PPGconn): cstring {.cdecl, dynlib: dllName, importc: "PQdb",
                                        ...raises: [], tags: [], forbids: [].}

    proc pqdisplayTuples(res: PPGresult; fp: File; fillAlign: int32;
                         fieldSep: cstring; printHeader: int32; quiet: int32) {.
        cdecl, dynlib: dllName, importc: "PQdisplayTuples", ...raises: [], tags: [],
        forbids: [].}

    proc pqendcopy(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
                                           importc: "PQendcopy", ...raises: [],
                                           tags: [], forbids: [].}

    proc pqenv2encoding(): int32 {.cdecl, dynlib: dllName,
                                   importc: "PQenv2encoding", ...raises: [], tags: [],
                                   forbids: [].}

    proc pqerrorMessage(conn: PPGconn): cstring {.cdecl, dynlib: dllName,
        importc: "PQerrorMessage", ...raises: [], tags: [], forbids: [].}

    proc pqescapeBytea(bintext: cstring; binlen: int; bytealen: var int): cstring {.
        cdecl, dynlib: dllName, importc: "PQescapeBytea", ...raises: [], tags: [],
        forbids: [].}

    proc pqescapeString(till, from: cstring; len: int): int {.cdecl,
        dynlib: dllName, importc: "PQescapeString", ...raises: [], tags: [],
        forbids: [].}

    proc pqexec(conn: PPGconn; query: cstring): PPGresult {.cdecl, dynlib: dllName,
        importc: "PQexec", ...raises: [], tags: [], forbids: [].}

    proc pqexecParams(conn: PPGconn; command: cstring; nParams: int32;
                      paramTypes: POid; paramValues: cstringArray;
                      paramLengths, paramFormats: ptr int32; resultFormat: int32): PPGresult {.
        cdecl, dynlib: dllName, importc: "PQexecParams", ...raises: [], tags: [],
        forbids: [].}

    proc pqexecPrepared(conn: PPGconn; stmtName: cstring; nParams: int32;
                        paramValues: cstringArray;
                        paramLengths, paramFormats: ptr int32; resultFormat: int32): PPGresult {.
        cdecl, dynlib: dllName, importc: "PQexecPrepared", ...raises: [], tags: [],
        forbids: [].}

    proc pqfformat(res: PPGresult; field_num: int32): int32 {.cdecl,
        dynlib: dllName, importc: "PQfformat", ...raises: [], tags: [], forbids: [].}

    proc pqfinish(conn: PPGconn) {.cdecl, dynlib: dllName, importc: "PQfinish",
                                   ...raises: [], tags: [], forbids: [].}

    proc pqflush(conn: PPGconn): int32 {.cdecl, dynlib: dllName, importc: "PQflush",
                                         ...raises: [], tags: [], forbids: [].}

    proc pqfmod(res: PPGresult; field_num: int32): int32 {.cdecl, dynlib: dllName,
        importc: "PQfmod", ...raises: [], tags: [], forbids: [].}

    proc pqfn(conn: PPGconn; fnid: int32; result_buf, result_len: ptr int32;
              result_is_int: int32; args: PPQArgBlock; nargs: int32): PPGresult {.
        cdecl, dynlib: dllName, importc: "PQfn", ...raises: [], tags: [], forbids: [].}

    proc pqfname(res: PPGresult; field_num: int32): cstring {.cdecl,
        dynlib: dllName, importc: "PQfname", ...raises: [], tags: [], forbids: [].}

    proc pqfnumber(res: PPGresult; field_name: cstring): int32 {.cdecl,
        dynlib: dllName, importc: "PQfnumber", ...raises: [], tags: [], forbids: [].}

    proc pqfreemem(p: pointer) {.cdecl, dynlib: dllName, importc: "PQfreemem",
                                 ...raises: [], tags: [], forbids: [].}

    proc pqfsize(res: PPGresult; field_num: int32): int32 {.cdecl, dynlib: dllName,
        importc: "PQfsize", ...raises: [], tags: [], forbids: [].}

    proc pqftable(res: PPGresult; field_num: int32): Oid {.cdecl, dynlib: dllName,
        importc: "PQftable", ...raises: [], tags: [], forbids: [].}

    proc pqftablecol(res: PPGresult; field_num: int32): int32 {.cdecl,
        dynlib: dllName, importc: "PQftablecol", ...raises: [], tags: [], forbids: [].}

    proc pqftype(res: PPGresult; field_num: int32): Oid {.cdecl, dynlib: dllName,
        importc: "PQftype", ...raises: [], tags: [], forbids: [].}

    proc pqgetCopyData(conn: PPGconn; buffer: cstringArray; async: int32): int32 {.
        cdecl, dynlib: dllName, importc: "PQgetCopyData", ...raises: [], tags: [],
        forbids: [].}

    proc pqgetisnull(res: PPGresult; tup_num: int32; field_num: int32): int32 {.
        cdecl, dynlib: dllName, importc: "PQgetisnull", ...raises: [], tags: [],
        forbids: [].}

    proc pqgetlength(res: PPGresult; tup_num: int32; field_num: int32): int32 {.
        cdecl, dynlib: dllName, importc: "PQgetlength", ...raises: [], tags: [],
        forbids: [].}

    proc pqgetline(conn: PPGconn; str: cstring; len: int32): int32 {.cdecl,
        dynlib: dllName, importc: "PQgetline", ...raises: [], tags: [], forbids: [].}

    proc pqgetlineAsync(conn: PPGconn; buffer: cstring; bufsize: int32): int32 {.
        cdecl, dynlib: dllName, importc: "PQgetlineAsync", ...raises: [], tags: [],
        forbids: [].}

    proc pqgetResult(conn: PPGconn): PPGresult {.cdecl, dynlib: dllName,
        importc: "PQgetResult", ...raises: [], tags: [], forbids: [].}

    proc pqgetvalue(res: PPGresult; tup_num: int32; field_num: int32): cstring {.
        cdecl, dynlib: dllName, importc: "PQgetvalue", ...raises: [], tags: [],
        forbids: [].}

    proc pqhost(conn: PPGconn): cstring {.cdecl, dynlib: dllName, importc: "PQhost",
                                          ...raises: [], tags: [], forbids: [].}

    proc pqinitOpenSSL(do_ssl: int32; do_crypto: int32) {.cdecl, dynlib: dllName,
        importc: "PQinitOpenSSL", ...raises: [], tags: [], forbids: [].}

    proc pqisBusy(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
                                          importc: "PQisBusy", ...raises: [], tags: [],
                                          forbids: [].}

    proc pqisnonblocking(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQisnonblocking", ...raises: [], tags: [], forbids: [].}

    proc pqmakeEmptyPGresult(conn: PPGconn; status: ExecStatusType): PPGresult {.
        cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult", ...raises: [],
        tags: [], forbids: [].}

    proc pqmblen(s: cstring; encoding: int32): int32 {.cdecl, dynlib: dllName,
        importc: "PQmblen", ...raises: [], tags: [], forbids: [].}

    proc pqnfields(res: PPGresult): int32 {.cdecl, dynlib: dllName,
                                            importc: "PQnfields", ...raises: [],
                                            tags: [], forbids: [].}

    proc pqnotifies(conn: PPGconn): PPGNotify {.cdecl, dynlib: dllName,
        importc: "PQnotifies", ...raises: [], tags: [], forbids: [].}

    proc pqntuples(res: PPGresult): int32 {.cdecl, dynlib: dllName,
                                            importc: "PQntuples", ...raises: [],
                                            tags: [], forbids: [].}

    proc pqoidStatus(res: PPGresult): cstring {.cdecl, dynlib: dllName,
        importc: "PQoidStatus", ...raises: [], tags: [], forbids: [].}

    proc pqoidValue(res: PPGresult): Oid {.cdecl, dynlib: dllName,
                                           importc: "PQoidValue", ...raises: [],
                                           tags: [], forbids: [].}

    proc pqoptions(conn: PPGconn): cstring {.cdecl, dynlib: dllName,
        importc: "PQoptions", ...raises: [], tags: [], forbids: [].}

    proc pqparameterStatus(conn: PPGconn; paramName: cstring): cstring {.cdecl,
        dynlib: dllName, importc: "PQparameterStatus", ...raises: [], tags: [],
        forbids: [].}

    proc pqpass(conn: PPGconn): cstring {.cdecl, dynlib: dllName, importc: "PQpass",
                                          ...raises: [], tags: [], forbids: [].}

    proc pqport(conn: PPGconn): cstring {.cdecl, dynlib: dllName, importc: "PQport",
                                          ...raises: [], tags: [], forbids: [].}

    proc pqprepare(conn: PPGconn; stmtName, query: cstring; nParams: int32;
                   paramTypes: POid): PPGresult {.cdecl, dynlib: dllName,
        importc: "PQprepare", ...raises: [], tags: [], forbids: [].}

    proc pqprint(fout: File; res: PPGresult; ps: PPQprintOpt) {.cdecl,
        dynlib: dllName, importc: "PQprint", ...raises: [], tags: [], forbids: [].}

    proc pqprintTuples(res: PPGresult; fout: File; printAttName: int32;
                       terseOutput: int32; width: int32) {.cdecl, dynlib: dllName,
        importc: "PQprintTuples", ...raises: [], tags: [], forbids: [].}

    proc pqprotocolVersion(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQprotocolVersion", ...raises: [], tags: [], forbids: [].}

    proc pqputCopyData(conn: PPGconn; buffer: cstring; nbytes: int32): int32 {.
        cdecl, dynlib: dllName, importc: "PQputCopyData", ...raises: [], tags: [],
        forbids: [].}

    proc pqputCopyEnd(conn: PPGconn; errormsg: cstring): int32 {.cdecl,
        dynlib: dllName, importc: "PQputCopyEnd", ...raises: [], tags: [], forbids: [].}

    proc pqputline(conn: PPGconn; str: cstring): int32 {.cdecl, dynlib: dllName,
        importc: "PQputline", ...raises: [], tags: [], forbids: [].}

    proc pqputnbytes(conn: PPGconn; buffer: cstring; nbytes: int32): int32 {.cdecl,
        dynlib: dllName, importc: "PQputnbytes", ...raises: [], tags: [], forbids: [].}

    proc pqrequestCancel(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQrequestCancel", ...raises: [], tags: [], forbids: [].}

    proc pqreset(conn: PPGconn) {.cdecl, dynlib: dllName, importc: "PQreset",
                                  ...raises: [], tags: [], forbids: [].}

    proc pqresetPoll(conn: PPGconn): PostgresPollingStatusType {.cdecl,
        dynlib: dllName, importc: "PQresetPoll", ...raises: [], tags: [], forbids: [].}

    proc pqresetStart(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQresetStart", ...raises: [], tags: [], forbids: [].}

    proc pqresStatus(status: ExecStatusType): cstring {.cdecl, dynlib: dllName,
        importc: "PQresStatus", ...raises: [], tags: [], forbids: [].}

    proc pqresultErrorField(res: PPGresult; fieldcode: int32): cstring {.cdecl,
        dynlib: dllName, importc: "PQresultErrorField", ...raises: [], tags: [],
        forbids: [].}

    proc pqresultErrorMessage(res: PPGresult): cstring {.cdecl, dynlib: dllName,
        importc: "PQresultErrorMessage", ...raises: [], tags: [], forbids: [].}

    proc pqresultStatus(res: PPGresult): ExecStatusType {.cdecl, dynlib: dllName,
        importc: "PQresultStatus", ...raises: [], tags: [], forbids: [].}

    proc pqsendQuery(conn: PPGconn; query: cstring): int32 {.cdecl, dynlib: dllName,
        importc: "PQsendQuery", ...raises: [], tags: [], forbids: [].}

  See also https://www.postgresql.org/docs/current/libpq-async.html

    proc pqsendQueryParams(conn: PPGconn; command: cstring; nParams: int32;
                           paramTypes: POid; paramValues: cstringArray;
                           paramLengths, paramFormats: ptr int32;
                           resultFormat: int32): int32 {.cdecl, dynlib: dllName,
        importc: "PQsendQueryParams", ...raises: [], tags: [], forbids: [].}

    proc pqsendQueryPrepared(conn: PPGconn; stmtName: cstring; nParams: int32;
                             paramValues: cstringArray;
                             paramLengths, paramFormats: ptr int32;
                             resultFormat: int32): int32 {.cdecl, dynlib: dllName,
        importc: "PQsendQueryPrepared", ...raises: [], tags: [], forbids: [].}

    proc pqserverVersion(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQserverVersion", ...raises: [], tags: [], forbids: [].}

    proc pqsetClientEncoding(conn: PPGconn; encoding: cstring): int32 {.cdecl,
        dynlib: dllName, importc: "PQsetClientEncoding", ...raises: [], tags: [],
        forbids: [].}

    proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPGconn {.
        ...raises: [], tags: [], forbids: [].}

    proc pqsetdbLogin(pghost: cstring; pgport: cstring; pgoptions: cstring;
                      pgtty: cstring; dbName: cstring; login: cstring; pwd: cstring): PPGconn {.
        cdecl, dynlib: dllName, importc: "PQsetdbLogin", ...raises: [], tags: [],
        forbids: [].}

    proc pqsetErrorVerbosity(conn: PPGconn; verbosity: PGVerbosity): PGVerbosity {.
        cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity", ...raises: [],
        tags: [], forbids: [].}

    proc pqsetnonblocking(conn: PPGconn; arg: int32): int32 {.cdecl,
        dynlib: dllName, importc: "PQsetnonblocking", ...raises: [], tags: [],
        forbids: [].}

    proc pqsetNoticeProcessor(conn: PPGconn; theProc: PQnoticeProcessor;
                              arg: pointer): PQnoticeProcessor {.cdecl,
        dynlib: dllName, importc: "PQsetNoticeProcessor", ...raises: [], tags: [],
        forbids: [].}

    proc pqsetNoticeReceiver(conn: PPGconn; theProc: PQnoticeReceiver; arg: pointer): PQnoticeReceiver {.
        cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver", ...raises: [],
        tags: [], forbids: [].}

    proc pqSetSingleRowMode(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
        importc: "PQsetSingleRowMode", ...raises: [], tags: [], forbids: [].}

  See also https://www.postgresql.org/docs/current/libpq-single-row-mode.html

    proc pqsocket(conn: PPGconn): int32 {.cdecl, dynlib: dllName,
                                          importc: "PQsocket", ...raises: [], tags: [],
                                          forbids: [].}

    proc pqstatus(conn: PPGconn): ConnStatusType {.cdecl, dynlib: dllName,
        importc: "PQstatus", ...raises: [], tags: [], forbids: [].}

    proc pqtrace(conn: PPGconn; debug_port: File) {.cdecl, dynlib: dllName,
        importc: "PQtrace", ...raises: [], tags: [], forbids: [].}

    proc pqtransactionStatus(conn: PPGconn): PGTransactionStatusType {.cdecl,
        dynlib: dllName, importc: "PQtransactionStatus", ...raises: [], tags: [],
        forbids: [].}

    proc pqtty(conn: PPGconn): cstring {.cdecl, dynlib: dllName, importc: "PQtty",
                                         ...raises: [], tags: [], forbids: [].}

    proc pqunescapeBytea(strtext: cstring; retbuflen: var int): cstring {.cdecl,
        dynlib: dllName, importc: "PQunescapeBytea", ...raises: [], tags: [],
        forbids: [].}

    proc pquntrace(conn: PPGconn) {.cdecl, dynlib: dllName, importc: "PQuntrace",
                                    ...raises: [], tags: [], forbids: [].}

    proc pquser(conn: PPGconn): cstring {.cdecl, dynlib: dllName, importc: "PQuser",
                                          ...raises: [], tags: [], forbids: [].}