Home Explore Blog CI



postgresql

11th chunk of `doc/src/sgml/libpq.sgml`
96c1a9ba61685a781933a01d3d9e2046e68aebebdd935af70000000100000fa8
 the memory used by the <structname>PGconn</structname> object.
       The <structname>PGconn</structname> pointer must not be used again after
       <xref linkend="libpq-PQfinish"/> has been called.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQreset">
     <term><function>PQreset</function><indexterm><primary>PQreset</primary></indexterm></term>
     <listitem>
      <para>
       Resets the communication channel to the server.
<synopsis>
void PQreset(PGconn *conn);
</synopsis>
      </para>

      <para>
       This function will close the connection
       to the server and attempt to establish a new
       connection, using all the same
       parameters previously used.  This might be useful for
       error recovery if a working connection is lost.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQresetStart">
     <term><function>PQresetStart</function><indexterm><primary>PQresetStart</primary></indexterm></term>
     <term><function>PQresetPoll</function><indexterm><primary>PQresetPoll</primary></indexterm></term>
     <listitem>
      <para>
       Reset the communication channel to the server, in a nonblocking manner.

<synopsis>
int PQresetStart(PGconn *conn);

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

      <para>
       These functions will close the connection to the server and attempt to
       establish a new connection, using all the same
       parameters previously used. This can be useful for error recovery if a
       working connection is lost. They differ from <xref linkend="libpq-PQreset"/> (above) in that they
       act in a nonblocking manner. These functions suffer from the same
       restrictions as <xref linkend="libpq-PQconnectStartParams"/>, <function>PQconnectStart</function>
       and <function>PQconnectPoll</function>.
      </para>

      <para>
       To initiate a connection reset, call
       <xref linkend="libpq-PQresetStart"/>. If it returns 0, the reset has
       failed. If it returns 1, poll the reset using
       <function>PQresetPoll</function> in exactly the same way as you
       would create the connection using <function>PQconnectPoll</function>.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQpingParams">
     <term><function>PQpingParams</function><indexterm><primary>PQpingParams</primary></indexterm></term>
     <listitem>
      <para>
       <xref linkend="libpq-PQpingParams"/> reports the status of the
       server.  It accepts connection parameters identical to those of
       <xref linkend="libpq-PQconnectdbParams"/>, described above.  It is not
       necessary to supply correct user name, password, or database name
       values to obtain the server status; however, if incorrect values
       are provided, the server will log a failed connection attempt.

<synopsis>
PGPing PQpingParams(const char * const *keywords,
                    const char * const *values,
                    int expand_dbname);
</synopsis>

       The function returns one of the following values:

       <variablelist>
        <varlistentry id="libpq-PQpingParams-PQPING_OK">
         <term><literal>PQPING_OK</literal></term>
         <listitem>
          <para>
           The server is running and appears to be accepting connections.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-PQpingParams-PQPING_REJECT">
         <term><literal>PQPING_REJECT</literal></term>
         <listitem>
          <para>
           The server is running but is in a state that disallows connections
           (startup, shutdown, or crash recovery).
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-PQpingParams-PQPING_NO_RESPONSE">
         <term><literal>PQPING_NO_RESPONSE</literal></term>
         <listitem>
          <para>
           The server could not be contacted.  This might indicate

Title: PQresetStart, PQresetPoll, and PQpingParams: Connection Reset and Server Status Functions
Summary
This section details PQresetStart, PQresetPoll, and PQpingParams. PQresetStart and PQresetPoll are non-blocking alternatives to PQreset for resetting the server connection, useful for error recovery. PQpingParams reports the server status, accepting connection parameters and returning a PGPing enum indicating whether the server is running and accepting connections, rejecting connections, or not responding.