PG_RECVLOGICAL(1)
β¨ PG_RECVLOGICAL β¨ (that's the pg_recvlogical manual page, bestie π
)
okay so welcome to the pg_recvlogical glow-up πΈ this is the PostgreSQL 15.19 docs page for it, and we're gonna get you so comfy with it.
π NAME π
pg_recvlogical β control PostgreSQL logical decoding streams. that's the whole vibe. she controls them. she streams from them. she's booked and busy π
π¦ SYNOPSIS π¦
pg_recvlogical [option...]
literally that's it. options go brrr, no positional args, we love a clean queen β¨
π DESCRIPTION π
so pg_recvlogical controls logical decoding replication slots and streams data from those replication slots. both. multitasking icon π
it creates a replication-mode connection, which means it's subject to the same constraints as pg_receivewal(1), plus the constraints for logical replication (see Chapter 49). no cap, same rules apply π«Ά
here's a thing to know: pg_recvlogical has no equivalent to the logical decoding SQL interface's peek and get modes. instead, it sends replay confirmations for data lazily as it receives it, and on clean exit. so if you wanna examine pending data on a slot without consuming it, use pg_logical_slot_peek_changes instead. peek, don't yeet π
when pg_recvlogical receives a SIGHUP signal, it closes the current output file and opens a new one using the filename specified by the --file option. why do we care? because that's how you rotate the output file: first rename the current file, then send a SIGHUP signal to pg_recvlogical. iconic file-rotation behavior, honestly π
π OPTIONS π
at least one of the following options must be specified to select an action. pick your fighter bestie:
--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. and ooh,--two-phasecan be specified 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, it retries in a loop unless--no-loopis specified. the stream format is determined by the output plugin specified when the slot was created. and the connection must be to the same database used to create the slot β no wandering off π₯
--create-slot and --start can be specified together. but --drop-slot cannot be combined with another action. she's a solo act, respect it π«Ά
πΈ options that control the location and format of the output (and other replication behavior) πΈ
-E lsn,--endpos=lsnβ in--startmode, automatically stop replication and exit with normal exit status0when receiving reaches the specified LSN. if specified when not in--startmode, an error is raised. if there's a record with LSN exactly equal to lsn, the record will be output. heads up:--endposis 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 π§-f filename,--file=filenameβ write received and decoded transaction data into this file. use-for stdout β¨-F interval_seconds,--fsync-interval=interval_secondsβ specifies how oftenpg_recvlogicalshould issuefsync()calls to ensure the output file is safely flushed to disk. 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. 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 π-I lsn,--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. she's chill like that π-n,--no-loopβ when the connection to the server is lost, do not retry in a loop, just exit. no thoughts, head empty, goodbye π-o name[=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 π-P plugin,--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 π-s interval_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 π-S slot_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. one name, three moods π-t,--two-phaseβ enables decoding of prepared transactions. this option may only be specified with--create-slotβ-v,--verboseβ enables verbose mode. tell me everything bestie π£οΈ
π§ options that control the database connection parameters π§
-d dbname,--dbname=dbnameβ the database to connect to. see the description of the actions for what this means in detail. the dbname can be a connection string; if so, connection string parameters will override any conflicting command line options. defaults to the user name πΈ-h hostname-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 π¦-p port,--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 β¨-U user,--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 π€-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 π
π the bonus options π
-V,--versionβ print thepg_recvlogicalversion and exit π-?,--helpβ show help aboutpg_recvlogicalcommand line arguments, and exit π«Ά
π₯ 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 β pick your aesthetic π
π NOTES π
pg_recvlogical will preserve group permissions on the output files if group permissions are enabled on the source cluster. thoughtful icon behavior π
π EXAMPLES π
see Section 49.1 for an example π
β SEE ALSO β
pg_receivewal(1) β her sister, go say hi π«Ά
and that's the page!! PostgreSQL 15.19, dated 2026 β mwah, go stream some logical decoding bestie πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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