18
18
<refname>pg_recvlogical</refname>
19
<refpurpose>Control logical decoding (see <xref linkend="logicaldecoding">)
20
streams over a walsender connection.</refpurpose>
19
<refpurpose>control <productname>PostgreSQL</productname> logical decoding streams</refpurpose>
25
24
<command>pg_recvlogical</command>
26
<arg rep="repeat" choice="opt"><option>option</option></arg>
25
<arg rep="repeat" choice="opt"><replaceable>option</replaceable></arg>
30
<refsect1 id="R1-APP-PGRECVLOGICAL-1">
31
30
<title>Description</title>
33
32
<command>pg_recvlogical</command> controls logical decoding replication
34
33
slots and streams data from such replication slots.
37
37
It creates a replication-mode connection, so it is subject to the same
39
linkend="app-pgreceivexlog"><application>pg_receivexlog</application></link>,
40
plus those for logical replication (see <xref
41
linkend="logicaldecoding">).
38
constraints as <xref linkend="app-pgreceivexlog">, plus those for logical
39
replication (see <xref linkend="logicaldecoding">).
47
44
<title>Options</title>
50
<application>pg_recvlogical</application> runs in one of three modes, which
51
control its primary action:
47
At least one of the following options must be specified to select an action:
56
52
<term><option>--create-slot</option></term>
59
Create a new logical replication slot with the name specified in
60
<option>--slot</option>, using the output plugin
61
<option>--plugin</option>, then exit. The slot is created for the
62
database given in <option>--dbname</option>.
68
<term><option>--start</option></term>
71
Begin streaming changes from the logical replication slot with the name
72
specified in <option>--slot</option>, continuing until terminated with a
73
signal. If the server side change stream ends with a server
74
shutdown or disconnect, retry in a loop unless
75
<option>--no-loop</option> is specified. The stream format is
76
determined by the output plugin specified when the slot was created.
79
You must connect to the same database used to create the slot.
55
Create a new logical replication slot with the name specified by
56
<option>--slot</option>, using the output plugin specified by
57
<option>--plugin</option>, for the database specified
58
by <option>--dbname</option>.
88
67
Drop the replication slot with the name specified
89
in <option>--slot</option>, then exit.
68
by <option>--slot</option>, then exit.
74
<term><option>--start</option></term>
77
Begin streaming changes from the logical replication slot specified
78
by <option>--slot</option>, continuing until terminated by a
79
signal. If the server side change stream ends with a server shutdown
80
or disconnect, retry in a loop unless
81
<option>--no-loop</option> is specified.
85
The stream format is determined by the output plugin specified when
90
The connection must be to the same database used to create the slot.
98
<application>pg_recvlogical</application> supports all the usual
99
<literal>libpq</literal>-based options. These are explained in detail in
100
the documentation for
101
<link linkend="APP-PSQL"><application>psql</application></link> and for
102
<link linkend="libpq"><literal>libpq</literal></link>.
107
<term><option>-U <replaceable>user</replaceable></option></term>
108
<term><option>--username <replaceable>user</replaceable></option></term>
111
Username to connect as. Must have a suitable <literal>pg_hba.conf</literal>
112
entry allowing <literal>replication</literal> connections. Defaults to
113
current operating system user name.
119
<term><option>-d <replaceable>database</replaceable></option></term>
120
<term><option>--dbname <replaceable>database</replaceable></option></term>
123
The database to connect to in <literal>replication</literal> mode; see
124
mode descriptions for details. May be
125
a <link linkend="LIBPQ-CONNSTRING">libpq connstring</link>
126
instead. Defaults to user name.
132
<term><option>-h <replaceable>hostname-or-ip</replaceable></option></term>
133
<term><option>--host <replaceable>hostname-or-ip</replaceable></option></term>
136
Host or socket to connect
137
to. See <link linkend="APP-PSQL"><application>psql</application></link>
138
and <link linkend="libpq"><literal>libpq</literal></link>
145
<term><option>-p <replaceable>port</replaceable></option></term>
146
<term><option>--port <replaceable>port</replaceable></option></term>
149
Port number to connect to. See
150
<link linkend="R1-APP-PSQL-3"><application>psql</application></link>
151
for an explanation of default port choices when this is not
158
<term><option>-w</option></term>
159
<term><option>--no-password</option></term>
162
Prevent prompting for a password. Will exit with an error code if a
163
password is required but not available.
169
<term><option>-W</option></term>
170
<term><option>--password</option></term>
173
Provide a password for this connection. Please use the pgservice file
174
(see <xref linkend="libpq-pgservice">) or an environment variable
175
instead of this option.
98
<option>--create-slot</option> and <option>--start</option> can be
99
specified together. <option>--drop-slot</option> cannot be combined with
120
<term><option>-F <replaceable>interval_seconds</replaceable></option></term>
121
<term><option>--fsync-interval=<replaceable>interval_seconds</replaceable></option></term>
124
Specifies how often <application>pg_recvlogical</application> should
125
issue <function>fsync()</function> calls to ensure the output file is
126
safely flushed to disk.
130
The server will occasionally request the client to perform a flush and
131
report the flush position to the server. This setting is in addition
132
to that, to perform flushes more frequently.
136
Specifying an interval of <literal>0</literal> disables
137
issuing <function>fsync()</function> calls altogether, while still
138
reporting progress to the server. In this case, data could be lost in
139
the event of a crash.
145
<term><option>-I <replaceable>lsn</replaceable></option></term>
146
<term><option>--startpos=<replaceable>lsn</replaceable></option></term>
149
In <option>--start</option> mode, start replication from the given
150
LSN. For details on the effect of this, see the documentation
151
in <xref linkend="logicaldecoding">
152
and <xref linkend="protocol-replication">. Ignored in other modes.
203
158
<term><option>-n</option></term>
213
<term><option>-o <replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term>
214
<term><option>--option=<replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term>
168
<term><option>-o <replaceable>name</replaceable>[=<replaceable>value</replaceable>]</option></term>
169
<term><option>--option=<replaceable>name</replaceable>[=<replaceable>value</replaceable>]</option></term>
217
Pass the option <parameter>NAME</parameter> to the output plugin with,
218
if specified, the option value <parameter>NAME</parameter>. Which
172
Pass the option <replaceable>name</replaceable> to the output plugin with,
173
if specified, the option value <replaceable>value</replaceable>. Which
219
174
options exist and their effects depends on the used output plugin.
225
<term><option>-F <replaceable>interval_seconds</replaceable></option></term>
226
<term><option>--fsync-interval=<replaceable>interval_seconds</replaceable></option></term>
229
How often should <application>pg_recvlogical</application> issue sync
230
commands to ensure the <parameter>--outputfile</parameter> is safely
231
flushed to disk without being asked by the server to do so. Specifying
232
an interval of <literal>0</literal> disables issuing fsyncs altogether,
233
while still reporting progress the server. In this case, data may be
234
lost in the event of a crash.
240
180
<term><option>-P <replaceable>plugin</replaceable></option></term>
241
181
<term><option>--plugin=<replaceable>plugin</replaceable></option></term>
244
When creating a slot, use the logical decoding output
184
When creating a slot, use the specified logical decoding output
245
185
plugin. See <xref linkend="logicaldecoding">. This option has no
246
186
effect if the slot already exists.
277
<term><option>-I <replaceable>lsn</replaceable></option></term>
278
<term><option>--startpos=<replaceable>lsn</replaceable></option></term>
281
In <option>--start</option> mode, start replication from the given
282
LSN. For details on the effect of this, see the documentation
283
in <xref linkend="logicaldecoding">
284
and <xref linkend="protocol-replication">. Ignored in other modes.
293
The following additional options are available:
298
216
<term><option>-v</></term>
299
217
<term><option>--verbose</></term>
228
The following command-line options control the database connection parameters.
232
<term><option>-d <replaceable>database</replaceable></option></term>
233
<term><option>--dbname=<replaceable>database</replaceable></option></term>
236
The database to connect to. See the description of the actions for
237
what this means in detail. This can be a libpq connection string;
238
see <xref linkend="LIBPQ-CONNSTRING"> for more information. Defaults
245
<term><option>-h <replaceable>hostname-or-ip</replaceable></option></term>
246
<term><option>--host=<replaceable>hostname-or-ip</replaceable></option></term>
249
Specifies the host name of the machine on which the server is
250
running. If the value begins with a slash, it is used as the
251
directory for the Unix domain socket. The default is taken
252
from the <envar>PGHOST</envar> environment variable, if set,
253
else a Unix domain socket connection is attempted.
259
<term><option>-p <replaceable>port</replaceable></option></term>
260
<term><option>--port=<replaceable>port</replaceable></option></term>
263
Specifies the TCP port or local Unix domain socket file
264
extension on which the server is listening for connections.
265
Defaults to the <envar>PGPORT</envar> environment variable, if
266
set, or a compiled-in default.
272
<term><option>-U <replaceable>user</replaceable></option></term>
273
<term><option>--username=<replaceable>user</replaceable></option></term>
276
Username to connect as. Defaults to current operating system user
283
<term><option>-w</option></term>
284
<term><option>--no-password</option></term>
287
Never issue a password prompt. If the server requires
288
password authentication and a password is not available by
289
other means such as a <filename>.pgpass</filename> file, the
290
connection attempt will fail. This option can be useful in
291
batch jobs and scripts where no user is present to enter a
298
<term><option>-W</option></term>
299
<term><option>--password</option></term>
302
Force <application>pg_recvlogical</application> to prompt for a
303
password before connecting to a database.
307
This option is never essential, since
308
<application>pg_recvlogical</application> will automatically prompt
309
for a password if the server demands password authentication.
310
However, <application>pg_recvlogical</application> will waste a
311
connection attempt finding out that the server wants a password.
312
In some cases it is worth typing <option>-W</> to avoid the extra
321
The following additional options are available:
308
325
<term><option>-V</></term>
309
326
<term><option>--version</></term>
349
<title>Environment</title>
352
This utility, like most other <productname>PostgreSQL</> utilities,
353
uses the environment variables supported by <application>libpq</>
354
(see <xref linkend="libpq-envars">).
359
<title>Examples</title>
362
See <xref linkend="logicaldecoding-example"> for an example.
367
<title>See Also</title>
369
<simplelist type="inline">
370
<member><xref linkend="app-pgreceivexlog"></member>