2 .\" Title: pg_recvlogical
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "PG_RECVLOGICAL" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 pg_recvlogical \- control PostgreSQL logical decoding streams
33 .HP \w'\fBpg_recvlogical\fR\ 'u
34 \fBpg_recvlogical\fR [\fIoption\fR...]
38 controls logical decoding replication slots and streams data from such replication slots\&.
40 It creates a replication\-mode connection, so it is subject to the same constraints as
41 \fBpg_receivewal\fR(1), plus those for logical replication (see
45 has no equivalent to the logical decoding SQL interface\*(Aqs 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
46 \fBpg_logical_slot_peek_changes\fR\&.
48 In the absence of fatal errors,
50 will run until terminated by the
60 signal, it closes the current output file and opens a new one using the filename specified by the
62 option\&. This allows us to rotate the output file by first renaming the current file and then sending a
68 At least one of the following options must be specified to select an action:
70 \fB\-\-create\-slot\fR
72 Create a new logical replication slot with the name specified by
73 \fB\-\-slot\fR, using the output plugin specified by
74 \fB\-\-plugin\fR, for the database specified by
81 are required for this action\&.
84 \fB\-\-enable\-two\-phase\fR
86 \fB\-\-enable\-failover\fR
87 options can be specified with
88 \fB\-\-create\-slot\fR\&.
93 Drop the replication slot with the name specified by
94 \fB\-\-slot\fR, then exit\&.
98 is required for this action\&.
103 Begin streaming changes from the logical replication slot specified by
104 \fB\-\-slot\fR, continuing until terminated by a signal\&. If the server side change stream ends with a server shutdown or disconnect, retry in a loop unless
113 are required for this action\&.
115 The stream format is determined by the output plugin specified when the slot was created\&.
117 The connection must be to the same database used to create the slot\&.
120 \fB\-\-create\-slot\fR
123 can be specified together\&.
125 cannot be combined with another action\&.
127 The following command\-line options control the location and format of the output and other replication behavior:
129 \fB\-E \fR\fB\fIlsn\fR\fR
131 \fB\-\-endpos=\fR\fB\fIlsn\fR\fR
135 mode, automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN\&. If specified when not in
137 mode, an error is raised\&.
139 If there\*(Aqs a record with LSN exactly equal to
140 \fIlsn\fR, the record will be output\&.
144 option is not aware of transaction boundaries and may truncate output partway through a transaction\&. Any partially output transaction will not be consumed and will be replayed again when the slot is next read from\&. Individual messages are never truncated\&.
147 \fB\-\-enable\-failover\fR
149 Enables the slot to be synchronized to the standbys\&. This option may only be specified with
150 \fB\-\-create\-slot\fR\&.
153 \fB\-f \fR\fB\fIfilename\fR\fR
155 \fB\-\-file=\fR\fB\fIfilename\fR\fR
157 Write received and decoded transaction data into this file\&. Use
162 This parameter is required for
166 \fB\-F \fR\fB\fIinterval_seconds\fR\fR
168 \fB\-\-fsync\-interval=\fR\fB\fIinterval_seconds\fR\fR
174 calls to ensure the output file is safely flushed to disk\&.
176 The server will occasionally request the client to perform a flush and report the flush position to the server\&. This setting is in addition to that, to perform flushes more frequently\&.
178 Specifying an interval of
182 calls altogether, while still reporting progress to the server\&. In this case, data could be lost in the event of a crash\&.
185 \fB\-I \fR\fB\fIlsn\fR\fR
187 \fB\-\-startpos=\fR\fB\fIlsn\fR\fR
191 mode, start replication from the given LSN\&. For details on the effect of this, see the documentation in
194 Section\ \&54.4\&. Ignored in other modes\&.
197 \fB\-\-if\-not\-exists\fR
199 Do not error out when
200 \fB\-\-create\-slot\fR
201 is specified and a slot with the specified name already exists\&.
208 When the connection to the server is lost, do not retry in a loop, just exit\&.
211 \fB\-o \fR\fB\fIname\fR\fR\fB[=\fR\fB\fIvalue\fR\fR\fB]\fR
213 \fB\-\-option=\fR\fB\fIname\fR\fR\fB[=\fR\fB\fIvalue\fR\fR\fB]\fR
217 to the output plugin with, if specified, the option value
218 \fIvalue\fR\&. Which options exist and their effects depends on the used output plugin\&.
221 \fB\-P \fR\fB\fIplugin\fR\fR
223 \fB\-\-plugin=\fR\fB\fIplugin\fR\fR
225 When creating a slot, use the specified logical decoding output plugin\&. See
226 Chapter\ \&47\&. This option has no effect if the slot already exists\&.
229 \fB\-s \fR\fB\fIinterval_seconds\fR\fR
231 \fB\-\-status\-interval=\fR\fB\fIinterval_seconds\fR\fR
233 This option has the same effect as the option of the same name in
234 \fBpg_receivewal\fR(1)\&. See the description there\&.
237 \fB\-S \fR\fB\fIslot_name\fR\fR
239 \fB\-\-slot=\fR\fB\fIslot_name\fR\fR
243 mode, use the existing logical replication slot named
244 \fIslot_name\fR\&. In
245 \fB\-\-create\-slot\fR
246 mode, create the slot with this name\&. In
248 mode, delete the slot with this name\&.
250 This parameter is required for any of actions\&.
255 \fB\-\-enable\-two\-phase\fR
257 \fB\-\-two\-phase\fR (deprecated)
259 Enables decoding of prepared transactions\&. This option may only be specified with
260 \fB\-\-create\-slot\fR\&.
267 Enables verbose mode\&.
270 The following command\-line options control the database connection parameters\&.
272 \fB\-d \fR\fB\fIdbname\fR\fR
274 \fB\-\-dbname=\fR\fB\fIdbname\fR\fR
276 The database to connect to\&. See the description of the actions for what this means in detail\&. The
279 connection string\&. If so, connection string parameters will override any conflicting command line options\&.
281 This parameter is required for
282 \fB\-\-create\-slot\fR
287 \fB\-h \fR\fB\fIhostname\-or\-ip\fR\fR
289 \fB\-\-host=\fR\fB\fIhostname\-or\-ip\fR\fR
291 Specifies the host name of the machine on which the server is running\&. If the value begins with a slash, it is used as the directory for the Unix domain socket\&. The default is taken from the
293 environment variable, if set, else a Unix domain socket connection is attempted\&.
296 \fB\-p \fR\fB\fIport\fR\fR
298 \fB\-\-port=\fR\fB\fIport\fR\fR
300 Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections\&. Defaults to the
302 environment variable, if set, or a compiled\-in default\&.
305 \fB\-U \fR\fB\fIuser\fR\fR
307 \fB\-\-username=\fR\fB\fIuser\fR\fR
309 User name to connect as\&. Defaults to current operating system user name\&.
314 \fB\-\-no\-password\fR
316 Never issue a password prompt\&. If the server requires password authentication and a password is not available by other means such as a
318 file, the connection attempt will fail\&. This option can be useful in batch jobs and scripts where no user is present to enter a password\&.
327 to prompt for a password before connecting to a database\&.
329 This option is never essential, since
331 will automatically prompt for a password if the server demands password authentication\&. However,
333 will waste a connection attempt finding out that the server wants a password\&. In some cases it is worth typing
335 to avoid the extra connection attempt\&.
338 The following additional options are available:
355 command line arguments, and exit\&.
360 will exit with status 0 when terminated by the
364 signal\&. (That is the normal way to end it\&. Hence it is not an error\&.) For fatal errors or other signals, the exit status will be nonzero\&.
367 This utility, like most other
369 utilities, uses the environment variables supported by
374 The environment variable
376 specifies whether to use color in diagnostic messages\&. Possible values are
384 will preserve group permissions on the received WAL files if group permissions are enabled on the source cluster\&.
391 \fBpg_receivewal\fR(1)