C client library

  • Non-blocking query execution
    • int PQsetnonblocking(PGconn *conn, int arg) - set a connection to be non-blocking
    • int PQsendQuery(PGconn *conn,const char *query) - send (buffer) a query
    • int PQflush(PGconn *conn) - attempt to flush buffer
    • PQconsumeInput(PGconn *conn) - read data from connection into underlying buffer
    • int PQisBusy(PGconn *conn) - is the query still being processed?
    • int PQrequestCancel(PGconn *conn) - cancel a running query
    • PGresult *PQgetResult(PGconn *conn)
      • Return usual result handle
      • Only call once !PQisBusy() to avoid blocking

    • Usage:
      • Call PQsetnonblocking();
      • Call PQsendQuery();
      • Do other stuff
      • PQconsumeInput() / PQisBusy() loop; select()
      • Process results, when ready

    • Useful applications: high-throughput applications, computationally intensive applicaitons
Prev

Next

Page 39