2 doc/src/sgml/ref/pg_recvlogical.sgml
3 PostgreSQL documentation
6 <refentry id="app-pgrecvlogical">
7 <indexterm zone="app-pgrecvlogical">
8 <primary>pg_recvlogical</primary>
12 <refentrytitle><application>pg_recvlogical</application></refentrytitle>
13 <manvolnum>1</manvolnum>
14 <refmiscinfo>Application</refmiscinfo>
18 <refname>pg_recvlogical</refname>
19 <refpurpose>control <productname>PostgreSQL</productname> logical decoding streams</refpurpose>
24 <command>pg_recvlogical</command>
25 <arg rep="repeat" choice="opt"><replaceable>option</replaceable></arg>
30 <title>Description</title>
32 <command>pg_recvlogical</command> controls logical decoding replication
33 slots and streams data from such replication slots.
37 It creates a replication-mode connection, so it is subject to the same
38 constraints as <xref linkend="app-pgreceivewal">, plus those for logical
39 replication (see <xref linkend="logicaldecoding">).
43 <command>pg_recvlogical</> has no equivalent to the logical decoding
44 SQL interface's peek and get modes. It sends replay confirmations for
45 data lazily as it receives it and on clean exit. To examine pending data on
46 a slot without consuming it, use
47 <link linkend="functions-replication"><function>pg_logical_slot_peek_changes</></>.
52 <title>Options</title>
55 At least one of the following options must be specified to select an action:
60 <term><option>--create-slot</option></term>
63 Create a new logical replication slot with the name specified by
64 <option>--slot</option>, using the output plugin specified by
65 <option>--plugin</option>, for the database specified
66 by <option>--dbname</option>.
72 <term><option>--drop-slot</option></term>
75 Drop the replication slot with the name specified
76 by <option>--slot</option>, then exit.
82 <term><option>--start</option></term>
85 Begin streaming changes from the logical replication slot specified
86 by <option>--slot</option>, continuing until terminated by a
87 signal. If the server side change stream ends with a server shutdown
88 or disconnect, retry in a loop unless
89 <option>--no-loop</option> is specified.
93 The stream format is determined by the output plugin specified when
98 The connection must be to the same database used to create the slot.
106 <option>--create-slot</option> and <option>--start</option> can be
107 specified together. <option>--drop-slot</option> cannot be combined with
112 The following command-line options control the location and format of the
113 output and other replication behavior:
117 <term><option>-E <replaceable>lsn</replaceable></option></term>
118 <term><option>--endpos=<replaceable>lsn</replaceable></option></term>
121 In <option>--start</option> mode, automatically stop replication
122 and exit with normal exit status 0 when receiving reaches the
123 specified LSN. If specified when not in <option>--start</option>
124 mode, an error is raised.
128 If there's a record with LSN exactly equal to <replaceable>lsn</>,
129 the record will be output.
133 The <option>--endpos</option> option is not aware of transaction
134 boundaries and may truncate output partway through a transaction.
135 Any partially output transaction will not be consumed and will be
136 replayed again when the slot is next read from. Individual messages
143 <term><option>-f <replaceable>filename</replaceable></option></term>
144 <term><option>--file=<replaceable>filename</replaceable></option></term>
147 Write received and decoded transaction data into this
148 file. Use <literal>-</> for <systemitem>stdout</systemitem>.
154 <term><option>-F <replaceable>interval_seconds</replaceable></option></term>
155 <term><option>--fsync-interval=<replaceable>interval_seconds</replaceable></option></term>
158 Specifies how often <application>pg_recvlogical</application> should
159 issue <function>fsync()</function> calls to ensure the output file is
160 safely flushed to disk.
164 The server will occasionally request the client to perform a flush and
165 report the flush position to the server. This setting is in addition
166 to that, to perform flushes more frequently.
170 Specifying an interval of <literal>0</literal> disables
171 issuing <function>fsync()</function> calls altogether, while still
172 reporting progress to the server. In this case, data could be lost in
173 the event of a crash.
179 <term><option>-I <replaceable>lsn</replaceable></option></term>
180 <term><option>--startpos=<replaceable>lsn</replaceable></option></term>
183 In <option>--start</option> mode, start replication from the given
184 LSN. For details on the effect of this, see the documentation
185 in <xref linkend="logicaldecoding">
186 and <xref linkend="protocol-replication">. Ignored in other modes.
192 <term><option>--if-not-exists</option></term>
195 Do not error out when <option>--create-slot</option> is specified
196 and a slot with the specified name already exists.
202 <term><option>-n</option></term>
203 <term><option>--no-loop</option></term>
206 When the connection to the server is lost, do not retry in a loop, just exit.
212 <term><option>-o <replaceable>name</replaceable>[=<replaceable>value</replaceable>]</option></term>
213 <term><option>--option=<replaceable>name</replaceable>[=<replaceable>value</replaceable>]</option></term>
216 Pass the option <replaceable>name</replaceable> to the output plugin with,
217 if specified, the option value <replaceable>value</replaceable>. Which
218 options exist and their effects depends on the used output plugin.
224 <term><option>-P <replaceable>plugin</replaceable></option></term>
225 <term><option>--plugin=<replaceable>plugin</replaceable></option></term>
228 When creating a slot, use the specified logical decoding output
229 plugin. See <xref linkend="logicaldecoding">. This option has no
230 effect if the slot already exists.
236 <term><option>-s <replaceable>interval_seconds</replaceable></option></term>
237 <term><option>--status-interval=<replaceable>interval_seconds</replaceable></option></term>
240 This option has the same effect as the option of the same name
241 in <xref linkend="app-pgreceivewal">. See the description there.
247 <term><option>-S <replaceable>slot_name</replaceable></option></term>
248 <term><option>--slot=<replaceable>slot_name</replaceable></option></term>
251 In <option>--start</option> mode, use the existing logical replication slot named
252 <replaceable>slot_name</replaceable>. In <option>--create-slot</option>
253 mode, create the slot with this name. In <option>--drop-slot</option>
254 mode, delete the slot with this name.
260 <term><option>-v</></term>
261 <term><option>--verbose</></term>
264 Enables verbose mode.
272 The following command-line options control the database connection parameters.
276 <term><option>-d <replaceable>database</replaceable></option></term>
277 <term><option>--dbname=<replaceable>database</replaceable></option></term>
280 The database to connect to. See the description of the actions for
281 what this means in detail. This can be a <application>libpq</application> connection string;
282 see <xref linkend="LIBPQ-CONNSTRING"> for more information. Defaults
289 <term><option>-h <replaceable>hostname-or-ip</replaceable></option></term>
290 <term><option>--host=<replaceable>hostname-or-ip</replaceable></option></term>
293 Specifies the host name of the machine on which the server is
294 running. If the value begins with a slash, it is used as the
295 directory for the Unix domain socket. The default is taken
296 from the <envar>PGHOST</envar> environment variable, if set,
297 else a Unix domain socket connection is attempted.
303 <term><option>-p <replaceable>port</replaceable></option></term>
304 <term><option>--port=<replaceable>port</replaceable></option></term>
307 Specifies the TCP port or local Unix domain socket file
308 extension on which the server is listening for connections.
309 Defaults to the <envar>PGPORT</envar> environment variable, if
310 set, or a compiled-in default.
316 <term><option>-U <replaceable>user</replaceable></option></term>
317 <term><option>--username=<replaceable>user</replaceable></option></term>
320 User name to connect as. Defaults to current operating system user
327 <term><option>-w</option></term>
328 <term><option>--no-password</option></term>
331 Never issue a password prompt. If the server requires
332 password authentication and a password is not available by
333 other means such as a <filename>.pgpass</filename> file, the
334 connection attempt will fail. This option can be useful in
335 batch jobs and scripts where no user is present to enter a
342 <term><option>-W</option></term>
343 <term><option>--password</option></term>
346 Force <application>pg_recvlogical</application> to prompt for a
347 password before connecting to a database.
351 This option is never essential, since
352 <application>pg_recvlogical</application> will automatically prompt
353 for a password if the server demands password authentication.
354 However, <application>pg_recvlogical</application> will waste a
355 connection attempt finding out that the server wants a password.
356 In some cases it is worth typing <option>-W</> to avoid the extra
365 The following additional options are available:
369 <term><option>-V</></term>
370 <term><option>--version</></term>
373 Print the <application>pg_recvlogical</application> version and exit.
379 <term><option>-?</></term>
380 <term><option>--help</></term>
383 Show help about <application>pg_recvlogical</application> command line
393 <title>Environment</title>
396 This utility, like most other <productname>PostgreSQL</> utilities,
397 uses the environment variables supported by <application>libpq</>
398 (see <xref linkend="libpq-envars">).
403 <title>Examples</title>
406 See <xref linkend="logicaldecoding-example"> for an example.
411 <title>See Also</title>
413 <simplelist type="inline">
414 <member><xref linkend="app-pgreceivewal"></member>