11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.120 2003/04/22 00:08:06 tgl Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.121 2003/04/28 04:29:11 tgl Exp $
33-->
44
55 <chapter id="libpq">
@@ -114,21 +114,26 @@ PGconn *PQconnectdb(const char *conninfo);
114114 used.
115115 </para>
116116 <para>
117- Using <literal>hostaddr</> instead of <literal>host</> allows the application to avoid a host
118- name look-up, which may be important in applications with time
119- constraints. However, Kerberos authentication requires the host
120- name. The following therefore applies: If <literal>host</> is specified without
121- <literal>hostaddr</>, a host name lookup is forced. If <literal>hostaddr</> is specified without
122- <literal>host</>, the value for <literal>hostaddr</> gives the remote address; if Kerberos is
123- used, this causes a reverse name query. If both <literal>host</> and <literal>hostaddr</> are
124- specified, the value for <literal>hostaddr</> gives the remote address; the value
125- for <literal>host</> is ignored, unless Kerberos is used, in which case that value
126- is used for Kerberos authentication. Note that authentication is likely
127- to fail if <application>libpq</application> is passed a host name that is not the name of the
128- machine at <literal>hostaddr</>.
117+ Using <literal>hostaddr</> instead of <literal>host</> allows the
118+ application to avoid a host name look-up, which may be important in
119+ applications with time constraints. However, Kerberos authentication
120+ requires the host name. The following therefore applies: If
121+ <literal>host</> is specified without <literal>hostaddr</>, a host name
122+ lookup is forced. If <literal>hostaddr</> is specified without
123+ <literal>host</>, the value for <literal>hostaddr</> gives the remote
124+ address; if Kerberos is used, this causes a reverse name query. If both
125+ <literal>host</> and <literal>hostaddr</> are specified, the value for
126+ <literal>hostaddr</> gives the remote address; the value for
127+ <literal>host</> is ignored, unless Kerberos is used, in which case that
128+ value is used for Kerberos authentication. (Note that authentication is
129+ likely to fail if <application>libpq</application> is passed a host name
130+ that is not the name of the machine at <literal>hostaddr</>.) Also,
131+ <literal>host</> rather than <literal>hostaddr</> is used to identify
132+ the connection in <filename>$HOME/.pgpass</>.
129133 </para>
130134 <para>
131- Without either a host name or host address, <application>libpq</application> will connect using a
135+ Without either a host name or host address,
136+ <application>libpq</application> will connect using a
132137 local Unix domain socket.
133138 </para>
134139 </listitem>
@@ -176,7 +181,8 @@ PGconn *PQconnectdb(const char *conninfo);
176181 <listitem>
177182 <para>
178183 Maximum wait for connection, in seconds (write as a decimal integer
179- string). Zero or not specified means infinite.
184+ string). Zero or not specified means wait indefinitely. It is not
185+ recommended to set the timeout to less than 2 seconds.
180186 </para>
181187 </listitem>
182188 </varlistentry>
@@ -2321,18 +2327,30 @@ information into simple client applications, for example.
23212327<indexterm>
23222328 <primary><envar>PGHOST</envar></primary>
23232329</indexterm>
2324- <envar>PGHOST</envar> sets thedefault server name.
2330+ <envar>PGHOST</envar> sets thedatabase server name.
23252331If this begins with a slash, it specifies Unix-domain communication
23262332rather than TCP/IP communication; the value is the name of the
23272333directory in which the socket file is stored (default <filename>/tmp</filename>).
23282334</para>
23292335</listitem>
23302336<listitem>
23312337<para>
2338+ <indexterm>
2339+ <primary><envar>PGHOSTADDR</envar></primary>
2340+ </indexterm>
2341+ <envar>PGHOSTADDR</envar> specifies the numeric IP address of the database
2342+ server. This can be set instead of <envar>PGHOST</envar> to avoid DNS
2343+ lookup overhead. See the documentation of
2344+ these parameters, under <function>PQconnectdb</function> above, for details
2345+ on their interaction.
2346+ </para>
2347+ </listitem>
2348+ <listitem>
2349+ <para>
23322350<indexterm>
23332351 <primary><envar>PGPORT</envar></primary>
23342352</indexterm>
2335- <envar>PGPORT</envar> sets thedefault TCP port number or Unix-domain
2353+ <envar>PGPORT</envar> sets the TCP port number or Unix-domain
23362354socket file extension for communicating with the
23372355<productname>PostgreSQL</productname> server.
23382356</para>
@@ -2342,7 +2360,7 @@ socket file extension for communicating with the
23422360<indexterm>
23432361 <primary><envar>PGDATABASE</envar></primary>
23442362</indexterm>
2345- <envar>PGDATABASE</envar> sets thedefault
2363+ <envar>PGDATABASE</envar> sets the
23462364<productname>PostgreSQL</productname> database name.
23472365</para>
23482366</listitem>
@@ -2369,6 +2387,19 @@ file (see <xref linkend="libpq-pgpass">).
23692387</listitem>
23702388<listitem>
23712389<para>
2390+ <indexterm>
2391+ <primary><envar>PGSERVICE</envar></primary>
2392+ </indexterm>
2393+ <envar>PGSERVICE</envar>
2394+ sets the service name to be looked up in <filename>pg_service.conf</filename>.
2395+ This offers a shorthand way of setting all the parameters.
2396+ </para>
2397+ </listitem>
2398+ <listitem>
2399+ <para>
2400+ <indexterm>
2401+ <primary><envar>PGREALM</envar></primary>
2402+ </indexterm>
23722403<envar>PGREALM</envar> sets the Kerberos realm to use with
23732404<productname>PostgreSQL</productname>, if it is different from the local realm.
23742405If <envar>PGREALM</envar> is set, <application>libpq</application>
@@ -2380,12 +2411,18 @@ used if Kerberos authentication is selected by the server.
23802411</listitem>
23812412<listitem>
23822413<para>
2414+ <indexterm>
2415+ <primary><envar>PGOPTIONS</envar></primary>
2416+ </indexterm>
23832417<envar>PGOPTIONS</envar> sets additional run-time options for
23842418the <productname>PostgreSQL</productname> server.
23852419</para>
23862420</listitem>
23872421<listitem>
23882422<para>
2423+ <indexterm>
2424+ <primary><envar>PGREQUIRESSL</envar></primary>
2425+ </indexterm>
23892426<envar>PGREQUIRESSL</envar> sets whether or not the connection must be
23902427made over <acronym>SSL</acronym>. If set to
23912428<quote>1</quote>, <application>libpq</>
@@ -2397,10 +2434,14 @@ This option is only available if
23972434</listitem>
23982435<listitem>
23992436<para>
2437+ <indexterm>
2438+ <primary><envar>PGCONNECT_TIMEOUT</envar></primary>
2439+ </indexterm>
24002440<envar>PGCONNECT_TIMEOUT</envar> sets the maximum number of seconds
24012441that <application>libpq</application> will wait when attempting to
2402- connect to the <productname>PostgreSQL</productname> server. This
2403- option should be set to at least 2 seconds.
2442+ connect to the <productname>PostgreSQL</productname> server. If unset
2443+ or set to zero, <application>libpq</application> will wait indefinitely.
2444+ It is not recommended to set the timeout to less than 2 seconds.
24042445</para>
24052446</listitem>
24062447</itemizedlist>
@@ -2413,27 +2454,39 @@ behavior for every <productname>PostgreSQL</productname> session.
24132454<itemizedlist>
24142455<listitem>
24152456<para>
2457+ <indexterm>
2458+ <primary><envar>PGDATESTYLE</envar></primary>
2459+ </indexterm>
24162460<envar>PGDATESTYLE</envar>
24172461sets the default style of date/time representation.
24182462(Equivalent to <literal>SET datestyle TO ...</literal>.)
24192463</para>
24202464</listitem>
24212465<listitem>
24222466<para>
2467+ <indexterm>
2468+ <primary><envar>PGTZ</envar></primary>
2469+ </indexterm>
24232470<envar>PGTZ</envar>
24242471sets the default time zone.
24252472(Equivalent to <literal>SET timezone TO ...</literal>.)
24262473</para>
24272474</listitem>
24282475<listitem>
24292476<para>
2477+ <indexterm>
2478+ <primary><envar>PGCLIENTENCODING</envar></primary>
2479+ </indexterm>
24302480<envar>PGCLIENTENCODING</envar>
24312481sets the default client character set encoding.
24322482(Equivalent to <literal>SET client_encoding TO ...</literal>.)
24332483</para>
24342484</listitem>
24352485<listitem>
24362486<para>
2487+ <indexterm>
2488+ <primary><envar>PGGEQO</envar></primary>
2489+ </indexterm>
24372490<envar>PGGEQO</envar>
24382491sets the default mode for the genetic query optimizer.
24392492(Equivalent to <literal>SET geqo TO ...</literal>.)