Home Explore Blog CI



postgresql

13th chunk of `doc/src/sgml/postgres-fdw.sgml`
1bdc22ef055c8fec762b1f230fcf4966e40270a70b2750840000000100000fa6
 <literal>closed</literal> are
      <literal>true</literal>.
     </para>
     <para>
      Example usage of the function:
<screen>
postgres=# SELECT * FROM postgres_fdw_get_connections(true);
 server_name | user_name | valid | used_in_xact | closed | remote_backend_pid
-------------+-----------+-------+--------------+-----------------------------
 loopback1   | postgres  | t     | t            | f      |            1353340
 loopback2   | public    | t     | t            | f      |            1353120
 loopback3   |           | f     | t            | f      |            1353156
</screen>
      The output columns are described in
      <xref linkend="postgres-fdw-get-connections-columns"/>.
     </para>

    <table id="postgres-fdw-get-connections-columns">
     <title><function>postgres_fdw_get_connections</function> Output Columns</title>
     <tgroup cols="3">
      <thead>
       <row>
        <entry>Column</entry>
        <entry>Type</entry>
        <entry>Description</entry>
       </row>
      </thead>

      <tbody>
       <row>
        <entry><structfield>server_name</structfield></entry>
        <entry><type>text</type></entry>
        <entry>
         The foreign server name of this connection. If the server is
         dropped but the connection remains open (i.e., marked as
         invalid), this will be <literal>NULL</literal>.
        </entry>
       </row>
       <row>
        <entry><structfield>user_name</structfield></entry>
        <entry><type>text</type></entry>
        <entry>
         Name of the local user mapped to the foreign server of this
         connection, or <literal>public</literal> if a public mapping is used.
         If the user mapping is dropped but the connection remains open
         (i.e., marked as invalid), this will be <literal>NULL</literal>.
        </entry>
       </row>
       <row>
        <entry><structfield>valid</structfield></entry>
        <entry><type>boolean</type></entry>
        <entry>
         False if this connection is invalid, meaning it is used in
         the current transaction, but its foreign server or
         user mapping has been changed or dropped.
         The invalid connection will be closed at the end of
         the transaction. True is returned otherwise.
        </entry>
       </row>
       <row>
        <entry><structfield>used_in_xact</structfield></entry>
        <entry><type>boolean</type></entry>
        <entry>
         True if this connection is used in the current transaction.
        </entry>
       </row>
       <row>
        <entry><structfield>closed</structfield></entry>
        <entry><type>boolean</type></entry>
        <entry>
         True if this connection is closed, false otherwise.
         <literal>NULL</literal> is returned if <literal>check_conn</literal>
         is set to <literal>false</literal> or if the connection status check
         is not available on this platform.
        </entry>
       </row>
       <row>
        <entry><structfield>remote_backend_pid</structfield></entry>
        <entry><type>int4</type></entry>
        <entry>
         Process ID of the remote backend, on the foreign server,
         handling the connection.  If the remote backend is terminated and
         the connection is closed (with <literal>closed</literal> set to
         <literal>true</literal>), this still shows the process ID of
         the terminated backend.
        </entry>
       </row>
      </tbody>
     </tgroup>
    </table>

    </listitem>
   </varlistentry>

   <varlistentry>
    <term><function>postgres_fdw_disconnect(server_name text) returns boolean</function></term>
    <listitem>
     <para>
      This function discards the open connections that are established by
      <filename>postgres_fdw</filename> from the local session to
      the foreign server with the given name.  Note that there can be
      multiple connections to the given server using different user mappings.
      If the connections are used in the current

Title: Postgres FDW Connection Management Functions
Summary
The postgres_fdw foreign data wrapper provides functions to manage connections to foreign servers, including retrieving information about open connections with postgres_fdw_get_connections and discarding open connections with postgres_fdw_disconnect, allowing for better control over connection management and troubleshooting.