Home Explore Blog CI



postgresql

91th chunk of `doc/src/sgml/libpq.sgml`
82441c6b403d10664c38c3dac7620e4aab8a1471233032e00000000100000fa2
 or
           <xref linkend="libpq-PQcancelBlocking"/>, to actually open the
           socket. This is the connection state right after
           calling <xref linkend="libpq-PQcancelCreate"/>
           or <xref linkend="libpq-PQcancelReset"/>. No connection to the
           server has been initiated yet at this point. To actually start
           sending the cancel request use <xref linkend="libpq-PQcancelStart"/> or
           <xref linkend="libpq-PQcancelBlocking"/>.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-cancel-connection-started">
         <term><symbol>CONNECTION_STARTED</symbol></term>
         <listitem>
          <para>
           Waiting for connection to be made.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-cancel-connection-made">
         <term><symbol>CONNECTION_MADE</symbol></term>
         <listitem>
          <para>
           Connection OK; waiting to send.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-cancel-connection-awaiting-response">
         <term><symbol>CONNECTION_AWAITING_RESPONSE</symbol></term>
         <listitem>
          <para>
           Waiting for a response from the server.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-cancel-connection-ssl-startup">
         <term><symbol>CONNECTION_SSL_STARTUP</symbol></term>
         <listitem>
          <para>
           Negotiating SSL encryption.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry id="libpq-cancel-connection-gss-startup">
         <term><symbol>CONNECTION_GSS_STARTUP</symbol></term>
         <listitem>
          <para>
           Negotiating GSS encryption.
          </para>
         </listitem>
        </varlistentry>
       </variablelist>

       Note that, although these constants will remain (in order to maintain
       compatibility), an application should never rely upon these occurring in a
       particular order, or at all, or on the status always being one of these
       documented values. An application might do something like this:
<programlisting>
switch(PQcancelStatus(conn))
{
        case CONNECTION_STARTED:
            feedback = "Connecting...";
            break;

        case CONNECTION_MADE:
            feedback = "Connected to server...";
            break;
.
.
.
        default:
            feedback = "Connecting...";
}
</programlisting>
      </para>

      <para>
       The <literal>connect_timeout</literal> connection parameter is ignored
       when using <function>PQcancelPoll</function>; it is the application's
       responsibility to decide whether an excessive amount of time has elapsed.
       Otherwise, <function>PQcancelStart</function> followed by a
       <function>PQcancelPoll</function> loop is equivalent to
       <xref linkend="libpq-PQcancelBlocking"/>.
      </para>

     </listitem>
    </varlistentry>

    <varlistentry id="libpq-PQcancelStatus">
     <term><function>PQcancelStatus</function><indexterm><primary>PQcancelStatus</primary></indexterm></term>

     <listitem>
      <para>
       Returns the status of the cancel connection.
<synopsis>
ConnStatusType PQcancelStatus(const PGcancelConn *cancelConn);
</synopsis>
      </para>

      <para>
       The status can be one of a number of values.  However, only three of
       these are seen outside of an asynchronous cancel procedure:
       <symbol>CONNECTION_ALLOCATED</symbol>,
       <symbol>CONNECTION_OK</symbol> and
       <symbol>CONNECTION_BAD</symbol>. The initial state of a
       <function>PGcancelConn</function> that's successfully created using
       <xref linkend="libpq-PQcancelCreate"/> is <symbol>CONNECTION_ALLOCATED</symbol>.
       A cancel request that was successfully dispatched
       has the status <symbol>CONNECTION_OK</symbol>.  A failed
       cancel attempt is signaled by

Title: PQcancelStatus Connection States and Usage
Summary
This section details the possible connection states returned by `PQcancelStatus` during a cancellation attempt, including CONNECTION_AWAITING_RESPONSE, CONNECTION_SSL_STARTUP, and CONNECTION_GSS_STARTUP, in addition to those previously mentioned. It advises against relying on a specific order or values of these statuses and provides an example of how to use the status in an application. It clarifies that `connect_timeout` is ignored when using `PQcancelPoll` and that it's the application's responsibility to handle timeouts. Finally, it defines the `PQcancelStatus` function, reiterates the three most commonly seen states outside of asynchronous procedures (CONNECTION_ALLOCATED, CONNECTION_OK, CONNECTION_BAD), and notes that the initial state after using `PQcancelCreate` is CONNECTION_ALLOCATED.