Search code examples
cpostgresqllibpq

How to delete a PGPing result from PostgreSQL's libpq?


I am using the c interface to PostgreSQL, libpq.

If I do PQping() on the database, how do I free/delete the returned PGPing instance (to avoid memory leaks)?

Is there something like PQclear() but for PGPing instead of PGresult?


Solution

  • You don't.

    The PGPing return value is just an enumerated value. There's nothing to free.

    From src/interfaces/libpq/libpq-fe.h:

    typedef enum
    {
        PQPING_OK,                  /* server is accepting connections */
        PQPING_REJECT,              /* server is alive but rejecting connections */
        PQPING_NO_RESPONSE,         /* could not establish connection */
        PQPING_NO_ATTEMPT           /* connection not attempted (bad params) */
    } PGPing;