-
+
TCP/IP communication is
always used when a nonempty string is specified for this parameter.
-
+
Using hostaddr> instead of host> allows the
application to avoid a host name look-up, which might be important in
the connection in ~/.pgpass> (see
).
-
+
Without either a host name or host address,
libpq will connect using a
-
+
port
Make a connection to the database server in a nonblocking manner.
-
+
PGconn *PQconnectStart(const char *conninfo);
-
+
PostgresPollingStatusType PQconnectPoll(PGconn *conn);
-
+
These two functions are used to open a connection to a database server such
that your application's thread of execution is not blocked on remote I/O
PQconnectdb>, and so the application can manage this
operation in parallel with other activities.
-
+
The database connection is made using the parameters taken from the string
conninfo, passed to PQconnectStart. This string is in
these parameters under PQconnectdb above for details.
-
+
If you call PQtrace, ensure that the stream object
into which you trace will not block.
-
+
You ensure that the socket is in the appropriate state
-
+
To begin a nonblocking connection request, call conn = PQconnectStart("connection_info_string>").
If
conn is null, then
libpq> has been unable to allocate a new PGconn>
PQconnectStart, call status = PQstatus(conn). If status equals
CONNECTION_BAD, PQconnectStart has failed.
-
+
If PQconnectStart> succeeds, the next stage is to poll
libpq> so that it can proceed with the connection sequence.
has failed, or PGRES_POLLING_OK, indicating the connection
has been successfully made.
-
+
At any time during connection, the status of the connection can be
checked by calling PQstatus>. If this gives CONNECTION_BAD>, then the
during (and only during) an asynchronous connection procedure. These
indicate the current stage of the connection procedure and might be useful
to provide feedback to the user for example. These statuses are:
-
+
CONNECTION_STARTED
-
+
CONNECTION_MADE
-
+
CONNECTION_AWAITING_RESPONSE
-
+
CONNECTION_AUTH_OK
-
+
CONNECTION_SSL_STARTUP
-
+
CONNECTION_SETENV
-
+
Note that, although these constants will remain (in order to maintain
compatibility), an application should never rely upon these occurring in a
particular order, or at all, or on the status always being one of these
}
-
+
The connect_timeout connection parameter is ignored
when using PQconnectPoll; it is the application's
PQconnectPoll loop is equivalent to
PQconnectdb.
-
+
Note that if PQconnectStart returns a non-null pointer, you must call
PQfinish when you are finished with it, in order to dispose of
-
+
PQconndefaultsPQconndefaults>>
} PQconninfoOption;
-
+
Returns a connection options array. This can be used to determine
all possible PQconnectdb options and their
will depend on environment variables and other context. Callers
must treat the connection options data as read-only.
-
+
After processing the options array, free it by passing it to
PQconninfoFree. If this is not done, a small amount of memory
is leaked for each call to PQconndefaults.
-
+
-
+
void PQfinish(PGconn *conn);
-
+
Note that even if the server connection attempt fails (as
indicated by PQstatus), the application should call PQfinish
-
+
void PQreset(PGconn *conn);
-
+
This function will close the connection
to the server and attempt to reestablish a new
-
+
PQgetvalue
-
+
Returns a single field value of one row of a
int column_number);
-
+
For data in text format, the value returned by
PQgetvalue is a null-terminated character
this case too, but that is not ordinarily useful, since the
value is likely to contain embedded nulls.)
-
+
An empty string is returned if the field value is null. See
PQgetisnull> to distinguish null values from
empty-string values.
-
+
The pointer returned by PQgetvalue points
to storage that is part of the PGresult
-
+
PQgetisnull
in libpq
-
+
Tests a field for a null value. Row and column numbers start
int column_number);
-
+
This function returns 1 if the field is null and 0 if it
contains a non-null value. (Note that
-
+
PQgetlength
-
+
Returns the actual length of a field value in bytes. Row and
int column_number);
-
+
This is the actual data length for the particular data value,
that is, the size of the object pointed to by
-
+
PQnparams
-
+
Returns the number of parameters of a prepared statement.
int PQnparams(const PGresult *res);
-
+
This function is only useful when inspecting the result of
PQdescribePrepared>. For other types of queries it
-
+
PQparamtype
-
+
Returns the data type of the indicated statement parameter.
Oid PQparamtype(const PGresult *res, int param_number);
-
+
This function is only useful when inspecting the result of
PQdescribePrepared>. For other types of queries it
-
+
PQprint
-
+
Prints out all the rows and, optionally, the column names to
-
+
PQtrace
-
+
Enables tracing of the client/server communication to a debugging file stream.
void PQtrace(PGconn *conn, FILE *stream);
-
+
On Windows, if the
libpq> library and an application are
library and all applications using that library.
-
+
-
+
PQuntrace
-
+
Disables tracing started by PQtrace.
-
+
-
+
Miscellaneous Functions