Commit 092133be authored by Tom Lane's avatar Tom Lane

Okay, I've had it with PQsetdbLogin having slightly different defaults

than PQconnectdb.  Reimplement the former to use the same code as the
latter.  Fix documentation omissions while at it.
parent d08007ae
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.120 2003/04/22 00:08:06 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.121 2003/04/28 04:29:11 tgl Exp $
--> -->
<chapter id="libpq"> <chapter id="libpq">
...@@ -114,21 +114,26 @@ PGconn *PQconnectdb(const char *conninfo); ...@@ -114,21 +114,26 @@ PGconn *PQconnectdb(const char *conninfo);
used. used.
</para> </para>
<para> <para>
Using <literal>hostaddr</> instead of <literal>host</> allows the application to avoid a host Using <literal>hostaddr</> instead of <literal>host</> allows the
name look-up, which may be important in applications with time application to avoid a host name look-up, which may be important in
constraints. However, Kerberos authentication requires the host applications with time constraints. However, Kerberos authentication
name. The following therefore applies: If <literal>host</> is specified without requires the host name. The following therefore applies: If
<literal>hostaddr</>, a host name lookup is forced. If <literal>hostaddr</> is specified without <literal>host</> is specified without <literal>hostaddr</>, a host name
<literal>host</>, the value for <literal>hostaddr</> gives the remote address; if Kerberos is lookup is forced. If <literal>hostaddr</> is specified without
used, this causes a reverse name query. If both <literal>host</> and <literal>hostaddr</> are <literal>host</>, the value for <literal>hostaddr</> gives the remote
specified, the value for <literal>hostaddr</> gives the remote address; the value address; if Kerberos is used, this causes a reverse name query. If both
for <literal>host</> is ignored, unless Kerberos is used, in which case that value <literal>host</> and <literal>hostaddr</> are specified, the value for
is used for Kerberos authentication. Note that authentication is likely <literal>hostaddr</> gives the remote address; the value for
to fail if <application>libpq</application> is passed a host name that is not the name of the <literal>host</> is ignored, unless Kerberos is used, in which case that
machine at <literal>hostaddr</>. value is used for Kerberos authentication. (Note that authentication is
likely to fail if <application>libpq</application> is passed a host name
that is not the name of the machine at <literal>hostaddr</>.) Also,
<literal>host</> rather than <literal>hostaddr</> is used to identify
the connection in <filename>$HOME/.pgpass</>.
</para> </para>
<para> <para>
Without either a host name or host address, <application>libpq</application> will connect using a Without either a host name or host address,
<application>libpq</application> will connect using a
local Unix domain socket. local Unix domain socket.
</para> </para>
</listitem> </listitem>
...@@ -176,7 +181,8 @@ PGconn *PQconnectdb(const char *conninfo); ...@@ -176,7 +181,8 @@ PGconn *PQconnectdb(const char *conninfo);
<listitem> <listitem>
<para> <para>
Maximum wait for connection, in seconds (write as a decimal integer Maximum wait for connection, in seconds (write as a decimal integer
string). Zero or not specified means infinite. string). Zero or not specified means wait indefinitely. It is not
recommended to set the timeout to less than 2 seconds.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2321,7 +2327,7 @@ information into simple client applications, for example. ...@@ -2321,7 +2327,7 @@ information into simple client applications, for example.
<indexterm> <indexterm>
<primary><envar>PGHOST</envar></primary> <primary><envar>PGHOST</envar></primary>
</indexterm> </indexterm>
<envar>PGHOST</envar> sets the default server name. <envar>PGHOST</envar> sets the database server name.
If this begins with a slash, it specifies Unix-domain communication If this begins with a slash, it specifies Unix-domain communication
rather than TCP/IP communication; the value is the name of the rather than TCP/IP communication; the value is the name of the
directory in which the socket file is stored (default <filename>/tmp</filename>). directory in which the socket file is stored (default <filename>/tmp</filename>).
...@@ -2329,10 +2335,22 @@ directory in which the socket file is stored (default <filename>/tmp</filename>) ...@@ -2329,10 +2335,22 @@ directory in which the socket file is stored (default <filename>/tmp</filename>)
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGHOSTADDR</envar></primary>
</indexterm>
<envar>PGHOSTADDR</envar> specifies the numeric IP address of the database
server. This can be set instead of <envar>PGHOST</envar> to avoid DNS
lookup overhead. See the documentation of
these parameters, under <function>PQconnectdb</function> above, for details
on their interaction.
</para>
</listitem>
<listitem>
<para>
<indexterm> <indexterm>
<primary><envar>PGPORT</envar></primary> <primary><envar>PGPORT</envar></primary>
</indexterm> </indexterm>
<envar>PGPORT</envar> sets the default TCP port number or Unix-domain <envar>PGPORT</envar> sets the TCP port number or Unix-domain
socket file extension for communicating with the socket file extension for communicating with the
<productname>PostgreSQL</productname> server. <productname>PostgreSQL</productname> server.
</para> </para>
...@@ -2342,7 +2360,7 @@ socket file extension for communicating with the ...@@ -2342,7 +2360,7 @@ socket file extension for communicating with the
<indexterm> <indexterm>
<primary><envar>PGDATABASE</envar></primary> <primary><envar>PGDATABASE</envar></primary>
</indexterm> </indexterm>
<envar>PGDATABASE</envar> sets the default <envar>PGDATABASE</envar> sets the
<productname>PostgreSQL</productname> database name. <productname>PostgreSQL</productname> database name.
</para> </para>
</listitem> </listitem>
...@@ -2369,6 +2387,19 @@ file (see <xref linkend="libpq-pgpass">). ...@@ -2369,6 +2387,19 @@ file (see <xref linkend="libpq-pgpass">).
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGSERVICE</envar></primary>
</indexterm>
<envar>PGSERVICE</envar>
sets the service name to be looked up in <filename>pg_service.conf</filename>.
This offers a shorthand way of setting all the parameters.
</para>
</listitem>
<listitem>
<para>
<indexterm>
<primary><envar>PGREALM</envar></primary>
</indexterm>
<envar>PGREALM</envar> sets the Kerberos realm to use with <envar>PGREALM</envar> sets the Kerberos realm to use with
<productname>PostgreSQL</productname>, if it is different from the local realm. <productname>PostgreSQL</productname>, if it is different from the local realm.
If <envar>PGREALM</envar> is set, <application>libpq</application> If <envar>PGREALM</envar> is set, <application>libpq</application>
...@@ -2380,12 +2411,18 @@ used if Kerberos authentication is selected by the server. ...@@ -2380,12 +2411,18 @@ used if Kerberos authentication is selected by the server.
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGOPTIONS</envar></primary>
</indexterm>
<envar>PGOPTIONS</envar> sets additional run-time options for <envar>PGOPTIONS</envar> sets additional run-time options for
the <productname>PostgreSQL</productname> server. the <productname>PostgreSQL</productname> server.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGREQUIRESSL</envar></primary>
</indexterm>
<envar>PGREQUIRESSL</envar> sets whether or not the connection must be <envar>PGREQUIRESSL</envar> sets whether or not the connection must be
made over <acronym>SSL</acronym>. If set to made over <acronym>SSL</acronym>. If set to
<quote>1</quote>, <application>libpq</> <quote>1</quote>, <application>libpq</>
...@@ -2397,10 +2434,14 @@ This option is only available if ...@@ -2397,10 +2434,14 @@ This option is only available if
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGCONNECT_TIMEOUT</envar></primary>
</indexterm>
<envar>PGCONNECT_TIMEOUT</envar> sets the maximum number of seconds <envar>PGCONNECT_TIMEOUT</envar> sets the maximum number of seconds
that <application>libpq</application> will wait when attempting to that <application>libpq</application> will wait when attempting to
connect to the <productname>PostgreSQL</productname> server. This connect to the <productname>PostgreSQL</productname> server. If unset
option should be set to at least 2 seconds. or set to zero, <application>libpq</application> will wait indefinitely.
It is not recommended to set the timeout to less than 2 seconds.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
...@@ -2413,6 +2454,9 @@ behavior for every <productname>PostgreSQL</productname> session. ...@@ -2413,6 +2454,9 @@ behavior for every <productname>PostgreSQL</productname> session.
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGDATESTYLE</envar></primary>
</indexterm>
<envar>PGDATESTYLE</envar> <envar>PGDATESTYLE</envar>
sets the default style of date/time representation. sets the default style of date/time representation.
(Equivalent to <literal>SET datestyle TO ...</literal>.) (Equivalent to <literal>SET datestyle TO ...</literal>.)
...@@ -2420,6 +2464,9 @@ sets the default style of date/time representation. ...@@ -2420,6 +2464,9 @@ sets the default style of date/time representation.
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGTZ</envar></primary>
</indexterm>
<envar>PGTZ</envar> <envar>PGTZ</envar>
sets the default time zone. sets the default time zone.
(Equivalent to <literal>SET timezone TO ...</literal>.) (Equivalent to <literal>SET timezone TO ...</literal>.)
...@@ -2427,6 +2474,9 @@ sets the default time zone. ...@@ -2427,6 +2474,9 @@ sets the default time zone.
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGCLIENTENCODING</envar></primary>
</indexterm>
<envar>PGCLIENTENCODING</envar> <envar>PGCLIENTENCODING</envar>
sets the default client character set encoding. sets the default client character set encoding.
(Equivalent to <literal>SET client_encoding TO ...</literal>.) (Equivalent to <literal>SET client_encoding TO ...</literal>.)
...@@ -2434,6 +2484,9 @@ sets the default client character set encoding. ...@@ -2434,6 +2484,9 @@ sets the default client character set encoding.
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<indexterm>
<primary><envar>PGGEQO</envar></primary>
</indexterm>
<envar>PGGEQO</envar> <envar>PGGEQO</envar>
sets the default mode for the genetic query optimizer. sets the default mode for the genetic query optimizer.
(Equivalent to <literal>SET geqo TO ...</literal>.) (Equivalent to <literal>SET geqo TO ...</literal>.)
......
This diff is collapsed.
#! /bin/sh #! /bin/sh
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.29 2002/11/13 16:40:23 tgl Exp $ # $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.30 2003/04/28 04:29:12 tgl Exp $
me=`basename $0` me=`basename $0`
: ${TMPDIR=/tmp} : ${TMPDIR=/tmp}
...@@ -137,6 +137,7 @@ do ...@@ -137,6 +137,7 @@ do
--host=*) --host=*)
PGHOST=`expr "x$1" : "x--host=\(.*\)"` PGHOST=`expr "x$1" : "x--host=\(.*\)"`
export PGHOST export PGHOST
unset PGHOSTADDR
shift;; shift;;
--port=*) --port=*)
PGPORT=`expr "x$1" : "x--port=\(.*\)"` PGPORT=`expr "x$1" : "x--port=\(.*\)"`
...@@ -279,8 +280,10 @@ then ...@@ -279,8 +280,10 @@ then
if [ "$unix_sockets" = no ]; then if [ "$unix_sockets" = no ]; then
PGHOST=$hostname PGHOST=$hostname
export PGHOST export PGHOST
unset PGHOSTADDR
else else
unset PGHOST unset PGHOST
unset PGHOSTADDR
fi fi
PGPORT=65432 PGPORT=65432
export PGPORT export PGPORT
...@@ -397,6 +400,7 @@ else # not temp-install ...@@ -397,6 +400,7 @@ else # not temp-install
if [ "$unix_sockets" = no ]; then if [ "$unix_sockets" = no ]; then
PGHOST=$hostname PGHOST=$hostname
export PGHOST export PGHOST
unset PGHOSTADDR
fi fi
if [ -n "$PGPORT" ]; then if [ -n "$PGPORT" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment