the value for
the first <parameter>dbname</parameter> key word is checked to see
if it is a <firstterm>connection string</firstterm>. If so, it
is <quote>expanded</quote> into the individual connection
parameters extracted from the string. The value is considered to
be a connection string, rather than just a database name, if it
contains an equal sign (<literal>=</literal>) or it begins with a
URI scheme designator. (More details on connection string formats
appear in <xref linkend="libpq-connstring"/>.) Only the first
occurrence of <parameter>dbname</parameter> is treated in this way;
any subsequent <parameter>dbname</parameter> parameter is processed
as a plain database name.
</para>
<para>
In general the parameter arrays are processed from start to end.
If any key word is repeated, the last value (that is
not <symbol>NULL</symbol> or empty) is used. This rule applies in
particular when a key word found in a connection string conflicts
with one appearing in the <literal>keywords</literal> array. Thus,
the programmer may determine whether array entries can override or
be overridden by values taken from a connection string. Array
entries appearing before an expanded <parameter>dbname</parameter>
entry can be overridden by fields of the connection string, and in
turn those fields are overridden by array entries appearing
after <parameter>dbname</parameter> (but, again, only if those
entries supply non-empty values).
</para>
<para>
After processing all the array entries and any expanded connection
string, any connection parameters that remain unset are filled with
default values. If an unset parameter's corresponding environment
variable (see <xref linkend="libpq-envars"/>) is set, its value is
used. If the environment variable is not set either, then the
parameter's built-in default value is used.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-PQconnectdb">
<term><function>PQconnectdb</function><indexterm><primary>PQconnectdb</primary></indexterm></term>
<listitem>
<para>
Makes a new connection to the database server.
<synopsis>
PGconn *PQconnectdb(const char *conninfo);
</synopsis>
</para>
<para>
This function opens a new database connection using the parameters taken
from the string <literal>conninfo</literal>.
</para>
<para>
The passed string can be empty to use all default parameters, or it can
contain one or more parameter settings separated by whitespace,
or it can contain a <acronym>URI</acronym>.
See <xref linkend="libpq-connstring"/> for details.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-PQsetdbLogin">
<term><function>PQsetdbLogin</function><indexterm><primary>PQsetdbLogin</primary></indexterm></term>
<listitem>
<para>
Makes a new connection to the database server.
<synopsis>
PGconn *PQsetdbLogin(const char *pghost,
const char *pgport,
const char *pgoptions,
const char *pgtty,
const char *dbName,
const char *login,
const char *pwd);
</synopsis>
</para>
<para>
This is the predecessor of <xref linkend="libpq-PQconnectdb"/> with a fixed
set of parameters. It has the same functionality except that the
missing parameters will always take on default values. Write <symbol>NULL</symbol> or an
empty string for any one of the fixed parameters that is to be defaulted.
</para>
<para>
If the <parameter>dbName</parameter> contains
an <symbol>=</symbol> sign or has a valid connection <acronym>URI</acronym> prefix, it