linkend="sql-set-transaction"><literal>SET TRANSACTION
SNAPSHOT</literal></link> to read the state of the database at the moment
the slot was created. This transaction can then be used to dump the
database's state at that point in time, which afterwards can be updated
using the slot's contents without losing any changes.
</para>
<para>
Applications that do not require
snapshot export may suppress it with the <literal>SNAPSHOT 'nothing'</literal>
option.
</para>
</sect2>
</sect1>
<sect1 id="logicaldecoding-walsender">
<title>Streaming Replication Protocol Interface</title>
<para>
The commands
<itemizedlist>
<listitem>
<para><literal>CREATE_REPLICATION_SLOT <replaceable>slot_name</replaceable> LOGICAL <replaceable>output_plugin</replaceable></literal></para>
</listitem>
<listitem>
<para><literal>DROP_REPLICATION_SLOT <replaceable>slot_name</replaceable></literal> <optional> <literal>WAIT</literal> </optional></para>
</listitem>
<listitem>
<para><literal>START_REPLICATION SLOT <replaceable>slot_name</replaceable> LOGICAL ...</literal></para>
</listitem>
</itemizedlist>
are used to create, drop, and stream changes from a replication
slot, respectively. These commands are only available over a replication
connection; they cannot be used via SQL.
See <xref linkend="protocol-replication"/> for details on these commands.
</para>
<para>
The command <xref linkend="app-pgrecvlogical"/> can be used to control
logical decoding over a streaming replication connection. (It uses
these commands internally.)
</para>
</sect1>
<sect1 id="logicaldecoding-sql">
<title>Logical Decoding <acronym>SQL</acronym> Interface</title>
<para>
See <xref linkend="functions-replication"/> for detailed documentation on
the SQL-level API for interacting with logical decoding.
</para>
<para>
Synchronous replication (see <xref linkend="synchronous-replication"/>) is
only supported on replication slots used over the streaming replication interface. The
function interface and additional, non-core interfaces do not support
synchronous replication.
</para>
</sect1>
<sect1 id="logicaldecoding-catalogs">
<title>System Catalogs Related to Logical Decoding</title>
<para>
The <link linkend="view-pg-replication-slots"><structname>pg_replication_slots</structname></link>
view and the
<link linkend="monitoring-pg-stat-replication-view">
<structname>pg_stat_replication</structname></link>
view provide information about the current state of replication slots and
streaming replication connections respectively. These views apply to both physical and
logical replication. The
<link linkend="monitoring-pg-stat-replication-slots-view">
<structname>pg_stat_replication_slots</structname></link>
view provides statistics information about the logical replication slots.
</para>
</sect1>
<sect1 id="logicaldecoding-output-plugin">
<title>Logical Decoding Output Plugins</title>
<para>
An example output plugin can be found in the
<link linkend="test-decoding">
<filename>contrib/test_decoding</filename>
</link>
subdirectory of the PostgreSQL source tree.
</para>
<sect2 id="logicaldecoding-output-init">
<title>Initialization Function</title>
<indexterm zone="logicaldecoding-output-init">
<primary>_PG_output_plugin_init</primary>
</indexterm>
<para>
An output plugin is loaded by dynamically loading a shared library with
the output plugin's name as the library base name. The normal library
search path is used to locate the library. To provide the required output
plugin callbacks and to indicate that the library is actually an output
plugin it needs to provide a function named
<function>_PG_output_plugin_init</function>. This function is passed a