pg_create_logical_replication_slot()

A function for creating a logical replication slot

pg_create_logical_replication_slot() is a system function for creating a logical replication slot.

pg_create_logical_replication_slot() was added in PostgreSQL 9.4.

Usage

PostgreSQL 14 ~

pg_create_logical_replication_slot ( slot_name name, plugin name [, temporary boolean , two_phase boolean ] )
        → record ( slot_name name, lsn pg_lsn )

PostgreSQL 10 ~ PostgreSQL 13:

pg_create_logical_replication_slot ( slot_name name, plugin name [, temporary boolean ] )
        → record ( slot_name name, lsn pg_lsn )

PostgreSQL 9.4 ~ PostgreSQL 9.6:

pg_create_logical_replication_slot ( slot_name name, plugin name )
        → record ( slot_name name, lsn pg_lsn )

Change history

Examples

Using pg_create_logical_replication_slot() to create a logical replication slot with the test_decoding sample output plugin:

postgres=# SELECT * FROM pg_create_logical_replication_slot('test_slot_1', 'test_decoding');
  slot_name  |    lsn
-------------+-----------
 test_slot_1 | 0/3000758
(1 row)

postgres=# SELECT * FROM pg_replication_slots\gx
-[ RECORD 1 ]-------+--------------
slot_name           | test_slot_1
plugin              | test_decoding
slot_type           | logical
datoid              | 13756
database            | postgres
temporary           | f
active              | f
active_pid          |
xmin                |
catalog_xmin        | 722
restart_lsn         | 0/3000720
confirmed_flush_lsn | 0/3000758
wal_status          | reserved
safe_wal_size       |
two_phase           | f

Categories

Logical replication, System function

See also

pg_replication_slots, pg_copy_logical_replication_slot(), pg_drop_replication_slot(), pg_create_physical_replication_slot()