<!--
doc/src/sgml/ref/pg_recvlogical.sgml
PostgreSQL documentation
-->
<refentry id="app-pgrecvlogical">
<indexterm zone="app-pgrecvlogical">
<primary>pg_recvlogical</primary>
</indexterm>
<refmeta>
<refentrytitle><application>pg_recvlogical</application></refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname>pg_recvlogical</refname>
<refpurpose>control <productname>PostgreSQL</productname> logical decoding streams</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>pg_recvlogical</command>
<arg rep="repeat" choice="opt"><replaceable>option</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>pg_recvlogical</command> controls logical decoding replication
slots and streams data from such replication slots.
</para>
<para>
It creates a replication-mode connection, so it is subject to the same
constraints as <xref linkend="app-pgreceivewal"/>, plus those for logical
replication (see <xref linkend="logicaldecoding"/>).
</para>
<para>
<command>pg_recvlogical</command> has no equivalent to the logical decoding
SQL interface's peek and get modes. It sends replay confirmations for
data lazily as it receives it and on clean exit. To examine pending data on
a slot without consuming it, use
<link linkend="functions-replication"><function>pg_logical_slot_peek_changes</function></link>.
</para>
<para>
In the absence of fatal errors, <application>pg_recvlogical</application>
will run until terminated by the <systemitem>SIGINT</systemitem>
(<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>)
or <systemitem>SIGTERM</systemitem> signal.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
At least one of the following options must be specified to select an action:
<variablelist>
<varlistentry>
<term><option>--create-slot</option></term>
<listitem>
<para>
Create a new logical replication slot with the name specified by
<option>--slot</option>, using the output plugin specified by
<option>--plugin</option>, for the database specified
by <option>--dbname</option>.
</para>
<para>
The <option>--slot</option> and <option>--dbname</option> are required
for this action.
</para>
<para>
The <option>--two-phase</option> and <option>--failover</option> options
can be specified with <option>--create-slot</option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--drop-slot</option></term>
<listitem>
<para>
Drop the replication slot with the name specified
by <option>--slot</option>, then exit.
</para>
<para>
The <option>--slot</option> is required for this action.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--start</option></term>
<listitem>
<para>
Begin streaming changes from the logical replication slot specified
by <option>--slot</option>, continuing until terminated by a
signal. If the server side change stream ends with a server shutdown
or disconnect, retry in a loop unless
<option>--no-loop</option> is specified.
</para>
<para>
The <option>--slot</option> and <option>--dbname</option>,
<option>--file</option> are required for this action.
</para>
<para>
The stream format is determined by the output plugin specified when
the slot was created.
</para>
<para>
The connection must be to the same database used to create the slot.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<option>--create-slot</option> and <option>--start</option>