Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

29.2. Connection Status Functions

These functions may be used to interrogate the status of an existing database connection object.

Tip: libpq application programmers should be careful to maintain the PGconn abstraction. Use the accessor functions described below to get at the contents of PGconn. Reference to internal PGconn fields using libpq-int.h is not recommended because they are subject to change in the future.

The following functions return parameter values established at connection. These values are fixed for the life of the PGconn object.

PQdb

Returns the database name of the connection.

char *PQdb(const PGconn *conn);
PQuser

Returns the user name of the connection.

char *PQuser(const PGconn *conn);
PQpass

Returns the password of the connection.

char *PQpass(const PGconn *conn);
PQhost

Returns the server host name of the connection.

char *PQhost(const PGconn *conn);
PQport

Returns the port of the connection.

char *PQport(const PGconn *conn);
PQtty

Returns the debug TTY of the connection. (This is obsolete, since the server no longer pays attention to the TTY setting, but the function remains for backwards compatibility.)

char *PQtty(const PGconn *conn);
PQoptions

Returns the command-line options passed in the connection request.

char *PQoptions(const PGconn *conn);

The following functions return status data that can change as operations are executed on the PGconn object.

PQstatus