Home Explore Blog CI



postgresql

9th chunk of `doc/src/sgml/libpq.sgml`
387130142b1548f99c9eb9c4034270eec7584becea95988e0000000100000fa4
   depending on platform.  See <literal>POLLIN</literal>
       and <literal>POLLOUT</literal> from <function>poll(2)</function>,
       or <parameter>readfds</parameter> and
       <parameter>writefds</parameter> from <function>select(2)</function>,
       for more information.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQconndefaults">
     <term><function>PQconndefaults</function><indexterm><primary>PQconndefaults</primary></indexterm></term>
     <listitem>
      <para>
       Returns the default connection options.
<synopsis>
PQconninfoOption *PQconndefaults(void);

typedef struct
{
    char   *keyword;   /* The keyword of the option */
    char   *envvar;    /* Fallback environment variable name */
    char   *compiled;  /* Fallback compiled in default value */
    char   *val;       /* Option's current value, or NULL */
    char   *label;     /* Label for field in connect dialog */
    char   *dispchar;  /* Indicates how to display this field
                          in a connect dialog. Values are:
                          ""        Display entered value as is
                          "*"       Password field - hide value
                          "D"       Debug option - don't show by default */
    int     dispsize;  /* Field size in characters for dialog */
} PQconninfoOption;
</synopsis>
      </para>

      <para>
       Returns a connection options array.  This can be used to determine
       all possible <xref linkend="libpq-PQconnectdb"/> options and their
       current default values.  The return value points to an array of
       <structname>PQconninfoOption</structname> structures, which ends
       with an entry having a null <structfield>keyword</structfield> pointer.  The
       null pointer is returned if memory could not be allocated. Note that
       the current default values (<structfield>val</structfield> fields)
       will depend on environment variables and other context.  A
       missing or invalid service file will be silently ignored.  Callers
       must treat the connection options data as read-only.
      </para>

      <para>
       After processing the options array, free it by passing it to
       <xref linkend="libpq-PQconninfoFree"/>.  If this is not done, a small amount of memory
       is leaked for each call to <xref linkend="libpq-PQconndefaults"/>.
      </para>

     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQconninfo">
     <term><function>PQconninfo</function><indexterm><primary>PQconninfo</primary></indexterm></term>
     <listitem>
      <para>
       Returns the connection options used by a live connection.
<synopsis>
PQconninfoOption *PQconninfo(PGconn *conn);
</synopsis>
      </para>

      <para>
       Returns a connection options array.  This can be used to determine
       all possible <xref linkend="libpq-PQconnectdb"/> options and the
       values that were used to connect to the server. The return
       value points to an array of <structname>PQconninfoOption</structname>
       structures, which ends with an entry having a null <structfield>keyword</structfield>
       pointer. All notes above for <xref linkend="libpq-PQconndefaults"/> also
       apply to the result of <xref linkend="libpq-PQconninfo"/>.
      </para>

     </listitem>
    </varlistentry>


    <varlistentry id="libpq-PQconninfoParse">
     <term><function>PQconninfoParse</function><indexterm><primary>PQconninfoParse</primary></indexterm></term>
     <listitem>
      <para>
       Returns parsed connection options from the provided connection string.

<synopsis>
PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
</synopsis>
      </para>

      <para>
       Parses a connection string and returns the resulting options as an
       array; or returns <symbol>NULL</symbol> if there is a problem with the connection
       string.  This function can be used to extract
       the <xref linkend="libpq-PQconnectdb"/> options

Title: PQconndefaults, PQconninfo, and PQconninfoParse: Connection Option Functions
Summary
This section covers the functions PQconndefaults, PQconninfo, and PQconninfoParse, which deal with connection options. PQconndefaults returns an array of default connection options that can be used to determine all possible PQconnectdb options and their current default values, taking into account environment variables. PQconninfo returns an array of connection options used by a live connection, allowing determination of the values used to connect to the server. PQconninfoParse parses a connection string and returns the resulting options as an array, or NULL if there is a problem with the connection string. The structure PQconninfoOption is detailed with the various fields