the <command>EXPLAIN ANALYZE</command>
case.
</para>
<para>
If the <function>IterateDirectModify</function> pointer is set to
<literal>NULL</literal>, no attempts to execute a direct modification on the
remote server are taken.
</para>
<para>
<programlisting>
void
EndDirectModify(ForeignScanState *node);
</programlisting>
Clean up following a direct modification on the remote server. It is
normally not important to release palloc'd memory, but for example open
files and connections to the remote server should be cleaned up.
</para>
<para>
If the <function>EndDirectModify</function> pointer is set to
<literal>NULL</literal>, no attempts to execute a direct modification on the
remote server are taken.
</para>
</sect2>
<sect2 id="fdw-callbacks-truncate">
<title>FDW Routines for <command>TRUNCATE</command></title>
<para>
<programlisting>
void
ExecForeignTruncate(List *rels,
DropBehavior behavior,
bool restart_seqs);
</programlisting>
Truncate foreign tables. This function is called when
<xref linkend="sql-truncate"/> is executed on a foreign table.
<literal>rels</literal> is a list of <structname>Relation</structname>
data structures of foreign tables to truncate.
</para>
<para>
<literal>behavior</literal> is either <literal>DROP_RESTRICT</literal>
or <literal>DROP_CASCADE</literal> indicating that the
<literal>RESTRICT</literal> or <literal>CASCADE</literal> option was
requested in the original <command>TRUNCATE</command> command,
respectively.
</para>
<para>
If <literal>restart_seqs</literal> is <literal>true</literal>,
the original <command>TRUNCATE</command> command requested the
<literal>RESTART IDENTITY</literal> behavior, otherwise the
<literal>CONTINUE IDENTITY</literal> behavior was requested.
</para>
<para>
Note that the <literal>ONLY</literal> options specified
in the original <command>TRUNCATE</command> command are not passed to
<function>ExecForeignTruncate</function>. This behavior is similar to
the callback functions of <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> on
a foreign table.
</para>
<para>
<function>ExecForeignTruncate</function> is invoked once per
foreign server for which foreign tables are to be truncated.
This means that all foreign tables included in <literal>rels</literal>
must belong to the same server.
</para>
<para>
If the <function>ExecForeignTruncate</function> pointer is set to
<literal>NULL</literal>, attempts to truncate foreign tables will
fail with an error message.
</para>
</sect2>
<sect2 id="fdw-callbacks-row-locking">
<title>FDW Routines for Row Locking</title>
<para>
If an FDW wishes to support <firstterm>late row locking</firstterm> (as described
in <xref linkend="fdw-row-locking"/>), it must provide the following
callback functions:
</para>
<para>
<programlisting>
RowMarkType
GetForeignRowMarkType(RangeTblEntry *rte,
LockClauseStrength strength);
</programlisting>
Report which row-marking option to use for a foreign table.
<literal>rte</literal> is the <structname>RangeTblEntry</structname> node for the table
and <literal>strength</literal> describes the lock strength requested by the
relevant <literal>FOR UPDATE/SHARE</literal> clause, if any. The result must be
a member of the <literal>RowMarkType</literal> enum type.
</para>
<para>
This function is called during query planning for each foreign table that
appears in an <command>UPDATE</command>, <command>DELETE</command>, or <command>SELECT
FOR UPDATE/SHARE</command> query and is not the target of <command>UPDATE</command>
or <command>DELETE</command>.
</para>