Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/libpq.sgml`
5fcb8cdf6b132be558b75c0a44b7abf2259f89e1f05a655c0000000100000fa5
 <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
        is taken as a <parameter>conninfo</parameter> string in exactly the same way as
        if it had been passed to <xref linkend="libpq-PQconnectdb"/>, and the remaining
        parameters are then applied as specified for <xref linkend="libpq-PQconnectdbParams"/>.
      </para>

      <para>
        <literal>pgtty</literal> is no longer used and any value passed will
        be ignored.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQsetdb">
     <term><function>PQsetdb</function><indexterm><primary>PQsetdb</primary></indexterm></term>
     <listitem>
      <para>
   Makes a new connection to the database server.
<synopsis>
PGconn *PQsetdb(char *pghost,
                char *pgport,
                char *pgoptions,
                char *pgtty,
                char *dbName);
</synopsis>
     </para>

     <para>
      This is a macro that calls <xref linkend="libpq-PQsetdbLogin"/> with null pointers
      for the <parameter>login</parameter> and <parameter>pwd</parameter> parameters.  It is provided
      for backward compatibility with very old programs.
     </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQconnectStartParams">
     <term><function>PQconnectStartParams</function><indexterm><primary>PQconnectStartParams</primary></indexterm></term>
     <term><function>PQconnectStart</function><indexterm><primary>PQconnectStart</primary></indexterm></term>
     <term id="libpq-PQconnectPoll"><function>PQconnectPoll</function><indexterm><primary>PQconnectPoll</primary></indexterm></term>
     <listitem>
      <para>
       <indexterm><primary>nonblocking connection</primary></indexterm>
       Make a connection to the database server in a nonblocking manner.

<synopsis>
PGconn *PQconnectStartParams(const char * const *keywords,
                             const char * const *values,
                             int expand_dbname);

PGconn *PQconnectStart(const char *conninfo);

PostgresPollingStatusType PQconnectPoll(PGconn *conn);
</synopsis>
      </para>

      <para>
       These three 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
       whilst doing so. The point of this approach is that the waits for I/O to
       complete can occur in the application's main loop, rather than down inside
       <xref linkend="libpq-PQconnectdbParams"/> or <xref linkend="libpq-PQconnectdb"/>, and so the
       application can manage this operation in parallel with other activities.
      </para>

      <para>
       With <xref linkend="libpq-PQconnectStartParams"/>, the database connection is made
       using the parameters taken from the <literal>keywords</literal> and
       <literal>values</literal> arrays, and controlled by <literal>expand_dbname</literal>,
       as described above for <xref linkend="libpq-PQconnectdbParams"/>.
      </para>

      <para>

Title: PQsetdbLogin, PQsetdb, PQconnectStartParams, PQconnectStart, PQconnectPoll - Database Connection Functions (Continued)
Summary
This section describes PQsetdbLogin, which is similar to PQconnectdb but with a fixed parameter set and handles dbname parameters as connection strings. It also introduces PQsetdb, a macro calling PQsetdbLogin with null login and password. Furthermore, it explains PQconnectStartParams, PQconnectStart, and PQconnectPoll for establishing non-blocking database connections, enabling applications to manage I/O waits within their main loop.