CREATE_REPLICATION_SLOT

This page documents the preview (v2.21) version. Preview includes features under active development and is for development and testing only. For production, use the stable (v2024.1) version.

Requires replication connection.

This command can only be executed on a walsender backend which can be started by establishing a replication connection. A replication connection can be created by passing the parameter replication=database in the connection string. Refer to examples section.

Synopsis

Use the CREATE_REPLICATION_SLOT statement to create a replication slot.

Syntax

create_replication_slot ::= CREATE_REPLICATION_SLOT slot_name LOGICAL 
                            output_plugin 
                            [ NOEXPORT_SNAPSHOT | USE_SNAPSHOT ]

create_replication_slot

CREATE_REPLICATION_SLOTslot_nameLOGICALoutput_pluginNOEXPORT_SNAPSHOTUSE_SNAPSHOT

Semantics

slot_name

The name of the replication slot. The name of the replication slot must be unique across all databases.

output_plugin

The name of the output plugin used for logical decoding.

NOEXPORT_SNAPSHOT / USE_SNAPSHOT

Decides what to do with the snapshot created during logical slot initialization.

USE_SNAPSHOT indicates the intention of the client to consume the snapshot. This option must be used in a transaction, and CREATE_REPLICATION_SLOT must be the first command run in that transaction.

NOEXPORT_SNAPSHOT will just use the snapshot for logical decoding as normal but won't do anything else with it.

Examples

Establish a replication connection to the database yugabyte.

bin/ysqlsh "dbname=yugabyte replication=database"

Create a Replication Slot with name test_replication_slot and use the yboutput plugin.

yugabyte=# CREATE_REPLICATION_SLOT test_replication_slot LOGICAL yboutput;

Create a Replication Slot with name test_replication_slot and use the pgoutput plugin.

yugabyte=# CREATE_REPLICATION_SLOT test_replication_slot LOGICAL pgoutput;

See also