Home Explore Blog CI



postgresql

12th chunk of `doc/src/sgml/postgres-fdw.sgml`
55ce56351d6258179d8ebfa0494ceb2e867a3238e6808a8c0000000100000fa8
 <literal>use_scram_passthrough</literal> is
           only required on the client side (FDW side).
          </para>
         </listitem>

         <listitem>
          <para>
           The user mapping password is not used.
          </para>
         </listitem>

         <listitem>
          <para>
           The server running <filename>postgres_fdw</filename> and the remote
           server must have identical SCRAM secrets (encrypted passwords) for
           the user being used on <filename>postgres_fdw</filename> to
           authenticate on the foreign server (same salt and iterations, not
           merely the same password).
          </para>

          <para>
           As a corollary, if FDW connections to multiple hosts are to be
           made, for example for partitioned foreign tables/sharding, then all
           hosts must have identical SCRAM secrets for the users involved.
          </para>
         </listitem>

         <listitem>
          <para>
           The current session on the PostgreSQL instance that makes the
           outgoing FDW connections also must also use SCRAM authentication
           for its incoming client connection.  (Hence
           <quote>pass-through</quote>: SCRAM must be used going in and out.)
           This is a technical requirement of the SCRAM protocol.
          </para>
         </listitem>
        </itemizedlist>
       </para>
      </listitem>
     </varlistentry>

    </variablelist>
   </sect3>
 </sect2>

<sect2 id="postgres-fdw-functions">
  <title>Functions</title>

  <variablelist>
   <varlistentry>
    <term><function>postgres_fdw_get_connections(
      IN check_conn boolean DEFAULT false, OUT server_name text,
      OUT user_name text, OUT valid boolean, OUT used_in_xact boolean,
      OUT closed boolean, OUT remote_backend_pid int4)
      returns setof record</function></term>
    <listitem>
     <para>
      This function returns information about all open connections postgres_fdw
      has established from the local session to foreign servers. If there are
      no open connections, no records are returned.
     </para>
     <para>
      If <literal>check_conn</literal> is set to <literal>true</literal>,
      the function checks the status of each connection and shows
      the result in the <literal>closed</literal> column.
      This feature is currently available only on systems that support
      the non-standard <symbol>POLLRDHUP</symbol> extension to
      the <symbol>poll</symbol> system call, including Linux.
      This is useful to check if all connections used within
      a transaction are still open. If any connections are closed,
      the transaction cannot be committed successfully,
      so it is better to roll back as soon as a closed connection is detected,
      rather than continuing to the end. Users can roll back the transaction
      immediately if the function reports connections where both
      <literal>used_in_xact</literal> and <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>

Title: Postgres FDW Functions and Connection Management
Summary
The postgres_fdw foreign data wrapper provides a function, postgres_fdw_get_connections, to retrieve information about open connections to foreign servers, including connection status and usage, and also discusses connection management options, such as using SCRAM pass-through authentication and checking connection validity.