PG_RECVLOGICAL(1)
π pg_recvlogical(1) β bestie edition π
okay so this is the PostgreSQL 16.15 manual page for pg_recvlogical, and honestly? she's a whole vibe. let's get into it β¨
πΈ NAME πΈ
pg_recvlogical β the girl who controls PostgreSQL logical decoding streams. no cap, that's her job.
β¨ SYNOPSIS β¨
pg_recvlogical [option...]
π¦ DESCRIPTION π¦
okay so pg_recvlogical controls logical decoding replication slots and streams the data coming out of those slots. she's doing both. main character energy fr.
she creates a replication-mode connection, which means she's subject to the same constraints as pg_receivewal(1), plus the constraints for logical replication (peep Chapter 49 for that).
here's a thing to know though: pg_recvlogical has no equivalent to the logical decoding SQL interface's peek and get modes. nope. she sends replay confirmations for data lazily as she receives it, and also on clean exit. so if you want to look at pending data on a slot without consuming it, you gotta use pg_logical_slot_peek_changes. that's the move π
in the absence of fatal errors, pg_recvlogical will just keep running until she's terminated by the SIGINT (Ctrl+C, iconic) or SIGTERM signal. she's not gonna stop on her own, bestie.
and when she receives a SIGHUP signal? she closes the current output file and opens a new one using the filename specified by the --file option. this is literally how you rotate the output file: first rename the current file, then send a SIGHUP signal to pg_recvlogical. slay.
π OPTIONS π
at least one of the following options must be specified to select an action (pick your fighter):
--create-slotβ creates a new logical replication slot with the name specified by--slot, using the output plugin specified by--plugin, for the database specified by--dbname. you can also pass--two-phasetogether with--create-slotto enable decoding of prepared transactions π«Ά--drop-slotβ drops the replication slot with the name specified by--slot, then exits. bye bestie π--startβ begins streaming changes from the logical replication slot specified by--slot, continuing until terminated by a signal. if the server side change stream ends with a server shutdown or disconnect, she retries in a loop unless--no-loopis specified. the stream format is determined by the output plugin specified when the slot was created. the connection must be to the same database used to create the slot. important!!
--create-slot and --start can be specified together. --drop-slot cannot be combined with another action (she's a solo act, periodt).
π options that control output location + format + other replication behavior π
-Elsn,--endpos=lsn β in--startmode, automatically stop replication and exit with normal exit status0when receiving reaches the specified LSN. if you specify it when you're not in--startmode, an error is raised. π¨ if there's a record with LSN exactly equal to lsn, that record will be output. heads up: the--endposoption 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 though, so that's something π-ffilename,--file=filename β write received and decoded transaction data into this file. use-for stdout.-Finterval_seconds,--fsync-interval=interval_seconds β specifies how oftenpg_recvlogicalshould issuefsync()calls to make sure the output file is safely flushed to disk. the server will occasionally request the client to perform a flush and report the flush position back to the server. this setting is in addition to that, to perform flushes more frequently. specifying an interval of0disables issuingfsync()calls altogether, while still reporting progress to the server. in that case, data could be lost in the event of a crash π (you've been warned)-Ilsn,--startpos=lsn β in--startmode, start replication from the given LSN. for details on the effect of this, see the documentation in Chapter 49 and Section 55.4. ignored in other modes.--if-not-existsβ do not error out when--create-slotis specified and a slot with the specified name already exists. lowkey a lifesaver.-n,--no-loopβ when the connection to the server is lost, do not retry in a loop, just exit. no thoughts, head empty, we're out πͺ-oname[=value],--option=name[=value]* β pass the option name to the output plugin with, if specified, the option value value. which options exist and their effects depends on the used output plugin. iykyk.-Pplugin,--plugin=plugin β when creating a slot, use the specified logical decoding output plugin. see Chapter 49. this option has no effect if the slot already exists.-sinterval_seconds,--status-interval=interval_seconds β this option has the same effect as the option of the same name inpg_receivewal(1). see the description there.-Sslot_name,--slot=slot_name β in--startmode, use the existing logical replication slot named slot_name. in--create-slotmode, create the slot with this name. in--drop-slotmode, delete the slot with this name. she's versatile like that π-t,--two-phaseβ enables decoding of prepared transactions. this option may only be specified with--create-slot. don't try it anywhere else.-v,--verboseβ enables verbose mode. she'll tell you everything π£οΈ
πΈ options that control the database connection parameters πΈ
-ddbname,--dbname=dbname β the database to connect to. see the description of the actions for what this means in detail. dbname can be a connection string. if so, connection string parameters will override any conflicting command line options. defaults to the user name.-hhostname-or-ip,--host=hostname-or-ip β 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 thePGHOSTenvironment variable, if set, else a Unix domain socket connection is attempted.-pport,--port=port β specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. defaults to thePGPORTenvironment variable, if set, or a compiled-in default.-Uuser,--username=user β user name to connect as. defaults to current operating system user name.-w,--no-passwordβ never issue a password prompt. if the server requires password authentication and a password is not available by other means such as a.pgpassfile, the connection attempt will fail. this option can be useful in batch jobs and scripts where no user is present to enter a password. (she's not being rude, she just can't ask π)-W,--passwordβ forcepg_recvlogicalto prompt for a password before connecting to a database. this option is never essential, sincepg_recvlogicalwill automatically prompt for a password if the server demands password authentication. however,pg_recvlogicalwill waste a connection attempt finding out that the server wants a password. in some cases it is worth typing-Wto avoid the extra connection attempt. save yourself the round trip bestie π«Ά
π the extra little guys π
-V,--versionβ print thepg_recvlogicalversion and exit.-?,--helpβ show help aboutpg_recvlogicalcommand line arguments, and exit.
β EXIT STATUS β
pg_recvlogical will exit with status 0 when terminated by the SIGINT or SIGTERM signal. (that is the normal way to end it β hence it is not an error. she's not crashing, she's leaving on purpose π
) for fatal errors or other signals, the exit status will be nonzero.
π₯ ENVIRONMENT π₯
this utility, like most other PostgreSQL utilities, uses the environment variables supported by libpq (see Section 34.15).
the environment variable PG_COLOR specifies whether to use color in diagnostic messages. possible values are always, auto and never. make it pretty π
π NOTES π
pg_recvlogical will preserve group permissions on the output files if group permissions are enabled on the source cluster. respect the group, periodt.
π EXAMPLES π
see Section 49.1 for an example. (go look, it's worth it β¨)
π§ SEE ALSO π§
pg_receivewal(1) β her sister, also iconic.
and that's the whole page, bestie!! πβ¨ππ¦πΈπ π«Ά
this was PostgreSQL 16.15 documentation, dated 2026, and the page is PG_RECVLOGICAL(1) β go stream some changes, you've got this ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms