sortas="libpq">with libpq>
name in pg_service.conf that holds additional connection parameters.
This allows applications to specify only a service name so connection parameters
can be centrally maintained. See
- PREFIX>/share/pg_service.conf.sample> for
- information on how to set up the file.
+ share/pg_service.conf.sample> in the installation
+ directory for information on how to set up the file.
If any parameter is unspecified, then the corresponding
environment variable (see )
is checked. If the environment variable is not set either,
- then built-in defaults are used.
+ then the indicated built-in defaults are used.
Note that, although these constants will remain (in order to maintain
- compatibility), an application should never rely upon these appearing in a
+ 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
documented values. An application might do something like this:
libpq> includes logic to obtain values for
server_version> and client_encoding> anyway.
Applications are encouraged to use PQparameterStatus>
-rather than ad-hoc code to determine these values. (Beware however
+rather than ad hoc> code to determine these values.
+(Beware however
that on a pre-3.0 connection, changing client_encoding> via
SET> after connection startup will not be reflected by
PQparameterStatus>.) For server_version>,
are supported.
Currently, the possible values are 2 (2.0 protocol), 3 (3.0 protocol),
or zero (connection bad). This will not change after connection
-startup is complete, but it could theoretically change during a reset.
-The 3.0 protocol will normally be used when communicating with
+startup is complete, but it could theoretically change during a connection
+reset. The 3.0 protocol will normally be used when communicating with
PostgreSQL> 7.4 or later servers; pre-7.4 servers support
only protocol 2.0. (Protocol 1.0 is obsolete and not supported by
libpq.)
PQerrorMessage result will
include a trailing newline. The caller should not free the result
directly. It will be freed when the associated PGconn>
- handle is passed to PQfinish.
+ handle is passed to PQfinish. The result string
+ should not be expected to remain the same across operations on the
+ PGconn> structure.
You must define USE_SSL in order to get the
- prototype for this function. Doing this will also
+ correct prototype for this function. Doing this will also
automatically include
ssl.h from
OpenSSL.
Returns the column number (within its table) of the column making up
the specified query result column.
- Result column numbers start at 0.
+ Query-result column numbers start at 0, but table columns have nonzero
+ numbers.
int PQftablecol(const PGresult *res,
int column_number);
Creates a data structure containing the information needed to cancel
- a command issued through a particular database connection.
+ a command issued through a particular database connection.
PGcancel *PQgetCancel(PGconn *conn);
PGHOST sets the database server name.
If this begins with a slash, it specifies Unix-domain communication
-rather than TCP/IP communication; the value is the name of the
-directory in which the socket file is stored (default /tmp).
+rather than TCP/IP communication; the value is then the name of the
+directory in which the socket file is stored (in a default installation
+setup this would be /tmp).
PGHOSTADDR specifies the numeric IP address of the database
-server. This can be set instead of PGHOST to avoid DNS
-lookup overhead. See the documentation of
+server. This can be set instead of or in addition to PGHOST
+to avoid DNS lookup overhead. See the documentation of
these parameters, under PQconnectdb above, for details
on their interaction.
PGPASSWORD
sets the password used if the server demands password
authentication. This environment variable is deprecated for security
-reasons; consider migrating to use the $HOME/.pgpass>
+reasons; instead consider using the $HOME/.pgpass>
file (see ).
connection, then if that fails, trying a regular non-
SSL>
connection;
require> will try only an SSL>
connection. If
PostgreSQL> is compiled without SSL support,
-using option require> will cause an error, and options
-allow> and prefer> will be tolerated but
-
libpq> will be unable to negotiate an SSL>
+using option require> will cause an error, while options
+allow> and prefer> will be accepted but
+
libpq> will not in fact attempt an SSL>
connection.
The following environment variables can be used to specify default
behavior for each
PostgreSQL session.
-(See also the ALTER USER> and ALTER DATABASE>
+(See also the
+ and
+
commands for ways to set default behavior on a per-user or per-database
basis.)
(Equivalent to SET geqo TO ....)
+
+
+Refer to the
SQL command
+
+for information on correct values for these environment variables.
+
+
+The following environment variables determine internal behavior of
+
libpq; they override compiled-in defaults.
+
+
PGLOCALEDIR
-sets the directory containing the locale> files.
+sets the directory containing the locale> files for message
+internationalization.
-
-Refer to the
SQL command
SET
-for information on correct values for these environment variables.
libpq is reentrant and thread-safe if the
configure command-line option
---enable-thread-safety> has been used when the
+--enable-thread-safety> was used when the
PostgreSQL distribution was built. In
addition, you might need to use additional compiler command-line
options when you compile your application code. Refer to your
- To build (i.e., compile and link) your
libpq programs you need to
+ To build (i.e., compile and link) a program using
do all of the following things: